fix(ui): persist active resource tab in url, fix internal markdown links#3925
fix(ui): persist active resource tab in url, fix internal markdown links#3925TheodoreSpeaks wants to merge 5 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Improves markdown file previews by adding heading Reviewed by Cursor Bugbot for commit 865d7d7. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 0f95d73. Configure here.
Greptile SummaryThis PR fixes internal markdown anchor link handling in the file viewer's The key changes are:
Confidence Score: 4/5Safe to merge with minor fixes — the core navigation logic is correct but two edge cases need attention: scroll target precision within overflow containers, and the silent no-op when NavigateCtx is null for internal path links. Both P1 findings are real defects on the changed path: (1) scrollIntoView can misalign headings relative to the overflow container's viewport; (2) e.preventDefault is called unconditionally before the null-guard on navigate, making internal non-hash links silently dead if the context is ever absent. Neither causes data loss or a security issue, but both affect the primary user path (navigating via markdown links) described in this very fix. apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx — specifically the AnchorRenderer handleClick and the NavigateCtx null-guard logic Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User clicks anchor in MarkdownPreview] --> B{href provided?}
B -- No --> Z[No-op]
B -- Yes --> C[isInternalHref called]
C --> D{href starts with '#'?}
D -- Yes --> E[pathname='', hash=href]
D -- No --> F{new URL parseable?}
F -- Yes --> G{same origin?}
G -- Yes --> H[pathname + hash extracted]
G -- No --> I[return null = external]
F -- No --> J{starts with '/'?}
J -- Yes --> K[pathname + hash extracted from string]
J -- No --> I
E --> L[parsed = internal]
H --> L
K --> L
L --> M[handleClick fires]
I --> N[AnchorRenderer renders with target=_blank]
M --> O{modifier key held?}
O -- Yes --> P[browser default = new tab]
O -- No --> Q[e.preventDefault]
Q --> R{pathname === '' AND hash?}
R -- Yes --> S[document.getElementById hash.slice 1]
S --> T[el?.scrollIntoView smooth]
R -- No --> U{navigate context non-null?}
U -- Yes --> V[router.push pathname + hash]
U -- No --> W[⚠️ click silently dropped]
Reviews (1): Last reviewed commit: "Fix lint" | Re-trigger Greptile |
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx
Outdated
Show resolved
Hide resolved
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ec14b30. Configure here.

Summary
Currently refreshing a mothership task defaults to the last resource tab opened. This can be confusing for a user who just refreshed. Instead, persist the resource id to the url so on refresh the same resource is opened.
File resources can have internal links to different sections. Previously this would reopen the whole page. Instead, we should navigate to the appropriate section of that resource. This scrolls the webview to the correct location.
Intercepts all link clicks to markdown files and checks if link is internal, starting with "#". If so, attempt to scroll the container to that header.
Type of Change
Testing
Validated that file resources can have internal link and external links that both behave appropriately.
Validated that downloaded file still uses correct link formatting.
Checklist
Screenshots/Videos