Skip to content

Phase 4.5: agent context links (Ctrl+L / Ctrl+Shift+L) — 0.5.1 - #11

Merged
TeleporterGuy merged 14 commits into
masterfrom
phase-4.5-agent-links
Sep 27, 2026
Merged

TeleporterGuy merged 14 commits into
masterfrom
phase-4.5-agent-links

Conversation

@TeleporterGuy

Copy link
Copy Markdown
Owner

Summary

Cursor-style "add to chat" for any agent tab. In an editor or notebook tab:

  • Ctrl+L (⌘L) inserts an @ link to the selection — or the cursor line / focused cell when nothing is selected — into the task's agent input: @src/foo.ts (lines 10-24), @nb.ipynb (cell 2, id 3c8d9b5c, lines 3-5).
  • Ctrl+Shift+L (⌘⇧L) links the whole file: @src/foo.ts.
  • Also: editor context menu, notebook cell header + toolbar buttons, file-tree Link to agent, and palette entries listing the shortcuts.

Nothing is submitted. The link goes to the task's most recently used agent tab (Pi / Claude / Codex terminal or Claude chat), which is activated and focused. Terminal tabs get a bracketed paste with no newline; a link for a not-yet-resumed Pi/Claude tab waits until it starts. Unsaved buffers are saved first. With no agent tab, a short notice is shown.

Notebook cell ids: notebooks without stored ids (nbformat < 4.5) got random stand-in ids on every parse, and the tab re-reads on a timer, so linked ids could vanish. Stand-ins are now stable (cell-N), duplicate ids are made unique, and links name the cell by 1-based position plus the id only when the file stores it.

Also bumps to 0.5.1 and closes Phase 4.5 in ROADMAP.md. Includes one unrelated palette change (commands.ts: new AI tabs honour claudeDefaultView) from parallel Claude tab work, kept here on purpose.

Test plan

  • npm run typecheck, npm test (1039 passed), npm run build
  • Pi on Windows (Git Bash): link arrives without executing, Pi reads the right lines/cell
  • Codex on macOS
  • Claude Code: receives the link; attaches the whole file for @path and finds the section from cell/lines (accepted)
  • Windows CI (test-windows) on this PR

🤖 Generated with Claude Code

TeleporterGuy and others added 14 commits September 25, 2026 16:20
Clean @path token with the range in words ('@src/foo.ts (lines 10-24) ',
'@nb.ipynb (cell id, lines 3-5) ') so @-mention expansion in Claude Code
and Pi is not broken by a suffix. Links go to the task's most recently
used agent tab (per-window MRU), activated in its pane, via an
'agent-insert' window event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PTY agent tabs (Pi, Claude, Codex) paste the link (bracketed paste when
the TUI enabled it, no newline) and take focus; links that arrive before
the PTY is spawned or while scrollback replays are queued. The Claude
chat composer inserts at the caret. Both record agent-tab recency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tree

Editor: Monaco actions (keys + context menu) replace Monaco's own Ctrl+L
and Ctrl+Shift+L; the selection, else the cursor line, or the whole
file. Notebook: the same actions in the cell editor, a cell header
button and a toolbar button; with no cell editor focused, a capture
handler scoped to the notebook links the active cell or the notebook.
Unsaved buffers (and cells whose id is not on disk yet) are saved first.
File tree: 'Link to agent' in the context menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
'Link Selection to Agent' (Ctrl+L) and 'Link File to Agent'
(Ctrl+Shift+L) in the palette list the shortcuts with Windows labels.
A short banner explains when nothing was sent (no agent tab, save failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code expands @path into the whole file, so selection and cell
links attached entire files/notebooks. Only whole-file links are @
mentions now; selections are a bare path + range the agent reads itself.

Notebooks without stored cell ids got random stand-in ids on every
parse, and the tab re-reads the file on a timer, so linked ids could be
gone by the time the agent read the file. Stand-ins are now cell-N,
repeated ids are made unique, and links name the cell by position plus
its id only when the file stores it. Linking no longer saves just to
write ids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Testing in Claude showed a pointer is not enough: '@path (lines ...)'
attached the whole file, and a bare 'path (lines ...)' attached nothing,
leaving the agent to go read it. Ctrl+L now inserts a header naming the
file / cell / lines plus the lines themselves in a fenced block (fence
longer than any backtick run inside). Claude Code, Codex and Pi fold a
multi-line paste into a chip. Over 20k chars a pointer is sent instead,
with a notice. Cells read 'cell 1 of 5' so the numbering is clearly
1-based. Ctrl+Shift+L still sends @path.

PTY tabs hold a multi-line snippet until the TUI has turned bracketed
paste on, so a TUI still starting up never sees the newlines as Enter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Selections and cells are '@path (lines ...)' / '@nb.ipynb (cell N, id
...)' again — the form that worked in Codex and matches Cursor. Keeps
the stable notebook cell ids and the cell position from the earlier fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tab bar showed two Claude buttons (default mode plus the other one).
Now there is one: the chat icon when Settings picks chat, the Claude
mark for the terminal. An open tab can still be switched between the
two from its own tab. The palette entry is 'New Claude Tab' and opens
the same mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Links to an agent in the right pane of a closed split open the split
  and are delivered; inserts are queued per tab until it subscribes, so
  a tab that mounts later still gets them.
- PTY tabs paste only once attached (not merely spawn-started) and the
  agent TUI has turned bracketed paste on (10 s fallback), so links are
  not lost or typed into a starting TUI; a tab awaiting Resume says the
  link is queued.
- Recency follows the agent tab last typed in, not the last one shown.
- Palette commands act on the tab that had focus when the palette
  opened (no timer) and say so when none answers.
- Palette 'Link Selection' in a notebook uses the open cell editor's
  selection, like Ctrl+L; stored cell ids are read from the file's
  cells, not substring-matched.
- Notebook key handler uses Cmd on macOS / Ctrl elsewhere, matching
  Monaco; Control+L on a Mac no longer links from notebook chrome.
- Monaco addAction registrations are disposed with their editor.
- Tests for the insert queue, split routing, readiness, recency,
  palette routing, the shortcut matcher and stored cell ids.
- The palette's New Claude Tab (claudeDefaultView) keeps its commit;
  ROADMAP gains a 'one agent per task' parking-lot idea.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A small chip at the end of a non-empty selection in editors and notebook
cells, like Cursor's 'Add to chat', showing the platform shortcut. It
appears once the selection settles, only while the editor has focus and
the task has an agent tab, hides when the selection is cleared or the
editor blurs, and links like the shortcut when clicked (mousedown keeps
the editor's focus and selection).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TeleporterGuy
TeleporterGuy merged commit e14bbda into master Sep 27, 2026
2 checks passed
@TeleporterGuy
TeleporterGuy deleted the phase-4.5-agent-links branch October 1, 2026 14:23
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