Skip to content

feat: AI sidebar driving agent CLIs over the in-app MCP surface - #83

Merged
IAmJSD merged 7 commits into
mainfrom
t3code/add-ai-sidebar-streaming
Aug 30, 2026
Merged

IAmJSD merged 7 commits into
mainfrom
t3code/add-ai-sidebar-streaming

Conversation

@IAmJSD

@IAmJSD IAmJSD commented Aug 30, 2026

Copy link
Copy Markdown
Member

What

A new right-hand panel (View ▸ AI Panel, Cmd/Ctrl+Shift+A, off by default) that chats with a coding-agent harness whose hands are Schist's own MCP tools, pointed at the document open in the window: edits stream onto the canvas as they happen, each an ordinary undoable history entry, with tool calls and assistant text streaming into the transcript live.

Two backends, both through their SDKs rather than hand-parsed CLI output:

backend CLI driven through
Claude Code claude Claude Agent SDK, Rust port (claude-agent-sdk-rs 0.6)
Codex codex app-server protocol client (codex-codes 0.150, sync, no tokio)

No API keys — the panel drives whichever CLI the user is already logged into, and says so when neither is on PATH. Conversations resume across panel closes (session id / thread id kept); Stop interrupts Claude over its control channel and ends the Codex app-server (whose blocking read can't be interrupted).

How

  • crates/mcp becomes lib + bin. Per-session operations move onto SessionCtx (borrowed doc/editor-state/registry) so the headless stdio server and the app share one dispatch. A new catalog::Scope::Active publishes the same ~250 tools with no session id and no session management — the current document is the whole contract; switching tabs retargets the next call. The stdio binary's behavior is unchanged.
  • Claude Code: zero plumbing — the Agent SDK serves MCP in-process (SdkMcpServer), each JSON-RPC message queued to the UI thread and answered between frames through the normal after_change repaint path. Isolated config: no filesystem settings, no CLAUDE.md, only mcp__schist allowed.
  • Codex: spawns MCP servers as processes, so the app listens on a token-guarded loopback port and Codex spawns schist --mcp-bridge <addr> — this same binary pumping stdio into that socket. (Any stdio MCP client can reach a running app the same way, given the address and token.) Read-only sandbox, approvals never; the per-tool-call elicitation is accepted (the only server in the profile is our own), command/file approvals declined.
  • The prompt box follows the notes panel's hand-rolled text-entry pattern, joins the text_entry key context and the cancel_gesture escape chain.

Hardening found by testing

  • Unknown CLI stream messages (rate_limit_event, from CLI newer than the SDK's enum) are skipped instead of killing the turn.
  • A bridge request queued in the instant the drain ticker stands down gets a reply timeout instead of hanging the connection forever (observed race).
  • Codex's bubblewrap sandbox warning on userns-restricted hosts is harmless for MCP-only turns.

Testing

  • make build (release), cargo test -p schist-app -p schist-mcp (75 tests, incl. new Active-scope catalog + endpoint round-trip tests), stdio schist-mcp smoke test (init/list/create/invert).
  • Headless GUI (Xvfb + lavapipe), real turns: Claude "invert the image" → get_state → adjust_invert (canvas + History update live), follow-up "undo that" → cmd_edit_undo; Codex "invert it" → get_state → adjust_invert through the bridge.

Docs: new docs/ai-panel.md, plus README / docs/mcp.md / docs/architecture.md updates.

🤖 Generated with Claude Code

IAmJSD and others added 7 commits August 30, 2026 17:36
A new right-hand panel (View  AI Panel, Cmd/Ctrl+Shift+A) chats with a
coding-agent harness whose hands are Schist's own MCP tools, pointed at
the document open in the window: edits stream onto the canvas as they
happen, each one an ordinary undoable history entry. Two backends, both
through their SDKs rather than hand-parsed CLI output  Claude Code via
the Claude Agent SDK's Rust port (claude-agent-sdk-rs), Codex via its
app-server protocol (codex-codes). No API keys: the panel drives the CLI
the user is already logged into, and says so when neither is installed.

To host that, crates/mcp becomes a library plus the unchanged stdio
binary. The per-session operations move onto SessionCtx  borrowed views
of a document, editor state and registry  so the headless server and
the app share one dispatch, and a new catalog Scope::Active publishes
the same ~250 tools with no session id and no session management: the
current document is the whole contract, and switching tabs mid-
conversation retargets the next call.

Claude Code needs no plumbing at all  the SDK routes MCP through an
in-process server, answered on the UI thread between frames. Codex
spawns MCP servers as processes, so the app listens on a token-guarded
loopback port and Codex spawns `schist --mcp-bridge <addr>`, this same
binary pumping stdio into that socket (which also lets any stdio MCP
client reach a running app). Codex runs read-only/never-approve; its
per-tool-call elicitation is accepted  the only server in the profile
is our own  and command/file approvals are declined.

Learned the hard way, encoded here: unknown CLI message types
(rate_limit_event) must not kill a turn; a bridge request queued in the
instant the drain ticker stands down needs a reply timeout; escape has
to join the cancel_gesture chain because the always-on binding preempts
key listeners.

Both backends verified headlessly end to end (invert + undo via Claude,
invert via Codex, canvas and history updating live).

Co-Authored-By: Claude Fable 5 <[email protected]>
A dropdown under the panel header, remembered per harness (the slugs do
not travel between them). "Default" defers to the CLI's own
configuration; the Claude entries are the tier aliases the CLI resolves
itself (Opus, Sonnet, Haiku) and the Codex list is the SDK's bundled
catalog, so it tracks the crate rather than us.

The choice applies from the next message without restarting the
conversation: Claude Code switches its live session over the control
channel (set_model, told only when the selection changes), Codex takes
the model as a per-turn override on turn/start.

Verified against the real CLI: after picking Haiku, the session log
shows every request on claude-haiku-4-5.

Co-Authored-By: Claude Fable 5 <[email protected]>
…catalogs

The Model row and the header's harness toggle are gone. In their place,
a chip beside Send opens one picker for both decisions: a search box, a
rail with a mark per installed harness, and rows named the way model
pickers name things  "Claude Fable 5", "GPT-5.6-Terra"  each with the
harness and its own description underneath. Search spans every installed
harness; picking a row picks harness and model together.

The lists are live, not a hardcoded catalog: Claude Code reports its
account's models in the Agent SDK's initialize handshake (the same list
its /model picker shows) and Codex answers model/list on its app-server,
each probed once per run by a short-lived spawn, with the static catalog
as the fallback. Claude's rows are renamed from its aliases to versioned
names derived from resolvedModel (claude-haiku-4-5-20251001 reads
"Claude Haiku 4.5").

There is no "default" row: a user's coding default is not presumed to be
their pick in an image editor. The harness's recommendation seeds the
first selection only; from then on the chip simply remembers what was
last used here, per harness.

Co-Authored-By: Claude Fable 5 <[email protected]>
The row text painted straight past the popup's edge: a flex child sizes
to its content unless told otherwise, so the name and sub-label now sit
in min-width-zero children under overflow-hidden rows — and since this
UI kit has no text-engine ellipsis pass, the strings are trimmed to a
character budget with a real ellipsis, the way the rest of the chrome
truncates. The picked row's check mark stops being clipped by the same
change.

The hand-drawn rail marks are replaced with the actual logos: the Claude
spark (Simple Icons, CC0) and the OpenAI mark (LobeHub icon set, MIT),
as monochrome paths tinted by text colour like every other icon.

Co-Authored-By: Claude Fable 5 <[email protected]>
The only way to dismiss the panel was the View menu or its shortcut,
which nothing on the panel pointed to. An × beside the trash button now
closes it through the same toggle, so the open state keeps being a saved
preference — close it and it stays closed across launches, leave it open
and it comes back. The hidden-state status line says how to reopen it.

Co-Authored-By: Claude Fable 5 <[email protected]>
The model chip already says which harness is talking, with the same
mark; the header repeating it was noise. Title, clear and close remain.

Co-Authored-By: Claude Fable 5 <[email protected]>
field_reassign_with_default on the two ClaudeAgentOptions builders,
collapsible_match on the text-delta arm (now a match guard), and a
rustfmt pass over the AI files — no behavior change.

Co-Authored-By: Claude Fable 5 <[email protected]>
@IAmJSD
IAmJSD merged commit a317213 into main Aug 30, 2026
3 checks passed
@IAmJSD
IAmJSD deleted the t3code/add-ai-sidebar-streaming branch August 30, 2026 19:57
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