feat: add 'Open in workspace' button to read_file tool cards - #4
feat: add 'Open in workspace' button to read_file tool cards#4ChonSong wants to merge 2 commits into
Conversation
Inject a Lucide folder-open button inside buildToolCard() for tools classified as 'read' kind (_toolActionKind). Clicking opens the file in the workspace file-tree panel via openArtifactPath(). - toolReadPath computed upstream from _toolTargetLabel(tc) - Button rendered inside .tool-card-detail (expanded), with a !hasDetail fallback for cards without a snippet/args section - Uses data-ws-path attribute + dataset read to avoid JS string escaping in the inline onclick - CSS .tool-card-ws-open / .tool-card-ws-open-btn styled to match .tool-card-more pattern (blue link, 10px, opacity hover)
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This reverts commit 35fa241.
|
Closing — switching to extension approach. See ext/open-in-workspace branch and #5 for the replacement. |
Summary
Injects an "Open in workspace" button into
read_filetool cards so users can jump directly from a chat tool call to the file opened in the workspace file-tree panel.Problem
After the agent reads a file, the user sees the content in the tool card snippet but there is no click-through to locate that file in the workspace tree or open it in the editor. This breaks the read-edit workflow: you have to manually navigate the file tree to find the file the agent just read.
Solution
Add a Lucide
folder-openicon button labelled "Open in workspace" inside the tool card detail section forreadkind tools (_toolActionKindreturnsread). On click it callsopenArtifactPath(path)→openFile()→/api/file, the same mechanism used by clicks on artifacts in the workspace panel itself.static/ui.js—buildToolCard():toolReadPathfrom_toolTargetLabel(tc)forreadtools.tool-card-detail(expanded view)!hasDetail(cards with no snippet/args)static/style.css— new classes:.tool-card-ws-open— padding wrapper.tool-card-ws-open-btn— clean link-style button matching.tool-card-morepatternImplementation Details
toolKind ===read(classified by_toolActionKind`)_toolTargetLabel(tc)— getspatharg from tool callopenArtifactPath(path)— existing Workspace v1 functionevent.stopPropagation()prevents tool card toggle;this.dataset.wsPathavoids JS escaping in HTML attribute/api/file→_handle_file_readalready usessafe_resolve_ws()(TOCTOU/symlink protection)Related