Skip to content

feat(chat): cross-workbench Chat tool with Logit Lens / Patch Lens handoff - #128

Draft
jon-bell wants to merge 2 commits into
mainfrom
cursor-workbench-chat-tool-2643
Draft

feat(chat): cross-workbench Chat tool with Logit Lens / Patch Lens handoff#128
jon-bell wants to merge 2 commits into
mainfrom
cursor-workbench-chat-tool-2643

Conversation

@jon-bell

@jon-bell jon-bell commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Chat tool available across the whole workbench — a lightweight completion playground wired to the same model the rest of the workspace uses, with easy two-way handoff to the interpretability tools.

It fulfils the request:

  • Chatbot interface to the same model, reachable from any tool page.
  • Easy access from Logit Lens / Patch Lens via a "Spin out" action.
  • Spin a prompt out to see up to N tokens — pushes the current tool prompt into the chat and generates a continuation.
  • Capture a prompt back into Logit Lens (or Patch Lens) — a completed chat result can be sent straight into a tool's prompt editor.
  • Unobtrusive when not in use — collapsed to a slim right-edge strip by default on desktop; a bottom-right FAB + drawer on mobile.
  • E2E test coverage.

UX

  • Desktop: a collapsible right rail that shares horizontal space with the active tool. Collapsed → a thin Chat strip with an open button; expanded → header, transcript, and composer. Mounted at the workspace layout level so it appears on every tool page.
  • Mobile: a bottom-right MessageSquare FAB (mirrors the bottom-left charts drawer) opening a right-side slide-over with the same panel.
  • Composer: multi-line prompt, a max-new-tokens field (1–64), and ⌘/Ctrl+Enter to send (plain Enter is a newline), matching the app's other prompt inputs.
  • Each turn shows the prompt + generated continuation, with inline pending/error states and Logit Lens / Patch Lens capture actions.

Handoff model

  • Spin out (SpinOutButton in Logit Lens and Patch Lens): opens the chat, seeds the composer with the tool's prompt, and auto-generates a continuation.
  • Capture back: a completed message can be sent to a tool. If the current route is a compatible tool it injects into that chart's prompt editor; otherwise it creates a new chart and navigates to it.
  • Seed (tool → chat) and injection (chat → tool) are ephemeral channels in the store; the consuming components guard on a nonce so each handoff runs exactly once.

Implementation

  • Reuses the existing /models/start-generate NDIF flow — no backend changes. modelsApi.ts now exports a bare generateCompletion (no toast) for the rail's inline error UI, keeping useGenerate intact.
  • New useChat zustand store (persisted to localStorage, keyed per-workspace) holds rail open-state, composer drafts, and conversation history. Interrupted pending turns are surfaced as errors on rehydrate. This is the interim history home documented in CLAUDE.md (a DB-backed table is the eventual target).
  • New feature-local components under app/workbench/[workspaceId]/components/chat/: WorkbenchChat (layout switch), ChatRail, MobileChatDrawer, ChatPanel, ChatComposer, ChatMessageItem, SpinOutButton, and the useChatController hook (generation + handoff logic shared by desktop/mobile).
  • Minimal edits to layout.tsx, Lens2Controls.tsx, and the Patch Lens page/area to mount the rail and wire spin-out + injection.

Tests

  • tests/chat-handoff.spec.ts (no NDIF): rail is collapsed by default and toggles open; a seeded completed message is captured into the Logit Lens prompt editor (seeded lens2 chart via tests/seed-chat.cjs + seeded chat localStorage, so no model run is needed).
  • tests/chat.spec.ts (real NDIF): compose a prompt and generate a continuation; spin the lens prompt out to chat, generate, and capture the result back.

Verification

bunx tsc --noEmit (no new errors), eslint, knip, prettier --check, and next build all pass for the changed files.

Open in Web Open in Cursor 

cursoragent and others added 2 commits July 2, 2026 22:25
Add a collapsible Chat rail available on every workspace tool page. It talks
to the same model as the rest of the workspace via the existing generate
endpoint, and integrates with the interpretability tools:

- Spin out: push a Logit Lens / Patch Lens prompt into the chat and generate
  up to N tokens.
- Capture back: send a completed chat result into the Logit Lens or Patch
  Lens prompt editor.

The rail is collapsed to a slim strip by default (bottom-right FAB + drawer on
mobile) so it stays unobtrusive when idle. History is kept per-workspace in a
persisted zustand store; spin-out/injection are ephemeral handoff channels.

Co-authored-by: Jonathan Bell <jon@jonbell.net>
- chat-handoff.spec.ts (no NDIF): rail collapsed-by-default + toggle, and
  send-to-Logit-Lens handoff via a seeded chart + seeded chat message.
- chat.spec.ts (real NDIF): compose+generate a continuation, and spin the lens
  prompt out to chat then capture it back.
- seed-chat.cjs seeds a deterministic lens2 chart for the handoff spec.

Co-authored-by: Jonathan Bell <jon@jonbell.net>
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workbench Ready Ready Preview, Comment Jul 2, 2026 10:26pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 2, 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7806dcc6-379a-4916-b7e3-7b3e532b0fba

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor-workbench-chat-tool-2643

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.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview deployed

@argos-ci

argos-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 2 changed, 4 removed, 7 failures Jul 2, 2026, 10:43 PM

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.

2 participants