A session can put a file or an image on the user's screen - #212
Merged
Conversation
PR 4 of the session-mcp-tools spec: the open_in_editor and show_image handlers land behind the socket service PR 209 wired up. - mcptools.TOOLS grows the two schemas (path required; open_in_editor takes an optional 1-based line). Validation is the existing table-driven checker; line 0, wrong types, and stray arguments are rejected app-side. - app.py adds the handlers plus _mcp_resolve_file: relative paths resolve against the agent's cwd first, then the project root — the same order clickable file references use. open_in_editor requires the file inside the session's project (can_open_in_editor); show_image shows any readable image, with the lightbox's Open in Editor button gated on project membership, exactly like a clicked image reference. - window.py promotes _open_in_tab_editor to open_in_tab_editor: the tools must land in the calling session's own tab, never switch tabs the way the window-level picker may. E2E-verified headlessly: a throwaway instance drove both tools through the real socket (hello + call frames); the editor opened widget.py at line 12 and the lightbox presented a staged render, and all five negative paths (outside-project, missing file, non-image, line 0, missing path) returned their clean errors. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dyuyFPinBYmRVsRUHYRTQ
Member
Author
|
@claude review |
ghackett
marked this pull request as ready for review
August 8, 2026 18:11
|
Claude finished @ghackett's task in 2m 0s —— View job Review complete ✅
This is a clean, well-scoped PR. A few notes: Correctness
Nits (non-blocking)
Testing
No changes requested — looks ready to merge as described. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 4 of the session-mcp-tools spec: the
open_in_editorandshow_imagehandlers land behind the socket service #209 wired up. An agent can now put the file it's talking about on the user's screen — "I've put the failing test on screen" instead of hoping they click a path — and pop a screenshot, plot, or render into the in-app lightbox without launching an external viewer.What changed
mcptools.TOOLSgrows the two schemas:open_in_editor(path, line?)(line is 1-based, minimum 1) andshow_image(path). The existing table-driven validator covers them — wrong types,line: 0, and stray arguments are all rejected app-side, since the socket is reachable by any local process.app.pyadds the two handlers plus_mcp_resolve_file: a relative path resolves against the running agent's cwd first (it may have cd'd into a worktree), then the tab's project root — the same order clickable file references use (terminal._reference_roots).open_in_editorrequires the file inside the session's project (can_open_in_editor), converts the 1-based line to the editor's cursor, and opens via the calling tab's own editor.show_imagefollows the clicked-image-reference recipe: any readable image shows, inside the project or not; the lightbox's "Open in Editor" button only appears when the tab could actually open it.window.pypromotes_open_in_tab_editorto publicopen_in_tab_editor: a session-attributed call must land in the calling session's own tab — the window-level_open_in_editorpicks a tab by project membership and may switch tabs, which is the wrong door for an agent-driven open.Screenshots
A staged session called its own tools through the real socket.
open_in_editor("src/widget.py", line=12)— cursor at 12:1 in the status bar:show_imageon a staged render — lightbox over the window, with its Open in Editor button since the image lives inside the project:Verification
test_mcptools+test_mcp_shim+test_mcpserver), including new schema/validation coverage for both tools and the tool-list assertions updated to track the table.open_in_editorwith a relative path + line → editor opened at 12:1 ✔ (screenshot)show_imagewith an absolute path → lightbox presented ✔ (screenshot)/etc/hostname→ "That file is outside this session's project" ✔show_image→ "Not an image Collins can display" ✔line: 0→ "'line' must be at least 1" ✔path→ "Missing required argument: path" ✔Per the spec, v1 pre-allows nothing — both tools go through the CLI's normal permission prompts. Next up is PR 5,
notify_user.🤖 Generated with Claude Code
https://claude.ai/code/session_016dyuyFPinBYmRVsRUHYRTQ