Skip to content

feat: add 'Open in workspace' button to read_file tool cards - #4

Closed
ChonSong wants to merge 2 commits into
masterfrom
feat/open-in-workspace-btn
Closed

feat: add 'Open in workspace' button to read_file tool cards#4
ChonSong wants to merge 2 commits into
masterfrom
feat/open-in-workspace-btn

Conversation

@ChonSong

Copy link
Copy Markdown
Owner

Summary

Injects an "Open in workspace" button into read_file tool 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-open icon button labelled "Open in workspace" inside the tool card detail section for read kind tools (_toolActionKind returns read). On click it calls openArtifactPath(path)openFile()/api/file, the same mechanism used by clicks on artifacts in the workspace panel itself.

static/ui.jsbuildToolCard():

  • Compute toolReadPath from _toolTargetLabel(tc) for read tools
  • Render the workspace-open button inside .tool-card-detail (expanded view)
  • Fallback outside the detail div when !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-more pattern

Implementation Details

Aspect Detail
Trigger toolKind === read(classified by_toolActionKind`)
Path extraction _toolTargetLabel(tc) — gets path arg from tool call
Open mechanism openArtifactPath(path) — existing Workspace v1 function
Click handling event.stopPropagation() prevents tool card toggle; this.dataset.wsPath avoids JS escaping in HTML attribute
Backend No changes — /api/file_handle_file_read already uses safe_resolve_ws() (TOCTOU/symlink protection)

Related

  • Refs workspace v1 path-based identity architecture

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)
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 341de8a7-ab71-4a06-8c79-acbaf86ff563

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ChonSong

Copy link
Copy Markdown
Owner Author

Closing — switching to extension approach. See ext/open-in-workspace branch and #5 for the replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant