feat(pikchr): inline grammar, progress keep-alives, and UI card for diagram sub-sessions - #893
Merged
Merged
Conversation
…nt warnings, double timeout Diagram sub-session improvements for generate_pikchr: - Inline the full bundled Pikchr grammar text into the specialist's prompt instead of referencing the grammar file by path — the sub-session has no repo access, so a path was a dead reference. When the bundled grammar is missing or unreadable, the prompt falls back to naming the public grammar URL. Remote blox note sessions are unaffected and keep referencing the uploaded grammar file. - Stop surfacing accepted-render layout warnings to the parent session: the warnings text content and the renderWarnings structured field are gone from the tool result, and the now-unused warnings plumbing is removed from GenOutcome and PreviewOutcome. - Double the generate_pikchr wall-clock timeout from 10 to 20 minutes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
A generate_pikchr call was one silent MCP request for the entire specialist run, and Claude Code aborts any MCP tool call that produces no response or progress notification for 300 s — well under a long diagram run. The abort never reached the server-side worker, which kept going, accepted a render, and completed the child session with nobody left waiting: every specialist run past ~5 minutes failed in the parent while the diagram session finished cleanly. Claude Code's idle timer explicitly resets on progress, so the handler now takes its rmcp RequestContext and, while awaiting the worker, ticks a progress notification back to the caller every 30 s, reporting elapsed seconds (monotonic, no total) with a short liveness message. The keep-alive loop runs under select! against the worker's oneshot, so it stops the moment the worker reports or the call future is dropped. When the caller sends no progress token, the loop pends forever instead — the MCP spec only allows progress against a caller-provided token — and the call behaves exactly as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Since the Pikchr grammar was inlined into the diagram sub-session's first user message, opening a diagram session in the UI showed ~10.5 KB of grammar text as a wall in the first prompt bubble. Give the grammar the same treatment as the existing injected-context blocks (action, branch-history, launch-context): the backend now wraps it in a <pikchr-grammar> tag, and the session UI renders it as a collapsed, expandable card above the prompt text. - pikchr_subsession.rs: initial_prompt wraps the appended grammar in <pikchr-grammar>…</pikchr-grammar> instead of the plain "Pikchr grammar reference:" heading, and grammar_line points the specialist at the tagged block. The URL fallback (bundled grammar missing) is unchanged. Prompt tests updated. - sessionModalHelpers.ts: the tag whitelist previously lived in three hand-maintained regexes across two files; export a single XML_BLOCK_TAGS list (now including pikchr-grammar) and derive the block/open-tag patterns from it, so previews, hints, and titles keep stripping the new block. - SessionChatPane.svelte: derive parseContentSegments' tagPattern from XML_BLOCK_TAGS and map the new tag to a "Pikchr grammar" card with the BookOpen icon. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
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.
Summary
Improvements to the
generate_pikchrdiagram sub-session flow, covering reliability of long runs, the specialist's prompt, and how the injected grammar renders in the session UI.Inline the grammar in the sub-session prompt (
f445f116)renderWarningsstructured field are removed from the tool result, along with the now-unused plumbing inGenOutcome/PreviewOutcome.generate_pikchrwall-clock timeout is doubled from 10 to 20 minutes.Send MCP progress keep-alives during
generate_pikchr(28c65618)generate_pikchrcall was one silent MCP request for the entire specialist run, and Claude Code aborts any MCP tool call that produces no response or progress for 300 s — so every run past ~5 minutes failed in the parent while the child session finished cleanly with nobody left waiting.RequestContextand ticks a progress notification back to the caller every 30 s (monotonic elapsed seconds, no total) while awaiting the worker, underselect!against the worker's oneshot so it stops the moment the worker reports or the call is dropped. When the caller provides no progress token, the loop pends forever and the call behaves exactly as before, per the MCP spec.Collapse the inlined grammar into an expandable context card (
03e1d6a6)<pikchr-grammar>tag, and the session UI renders it as a collapsed, expandable "Pikchr grammar" card (BookOpen icon) above the prompt text — the same treatment as the existingaction/branch-history/launch-contextblocks.XML_BLOCK_TAGSlist that the block/open-tag patterns derive from.Test plan
<pikchr-grammar>block, URL fallback) and removal of the warnings plumbing.🤖 Generated with Claude Code