Inline AI schema explanations in the editor - #165
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds an agent-driven Explain control to the schema editor that overlays AI-generated explanations inline in Monaco without modifying the schema text. A tristate toggle (Off / Compact / Full) controls density; a Regenerate button re-runs the agent on demand. - Off: clean schema. Compact: a short ghost tag at each symbol's line end, click to expand its full block. Full: an indented explanation block above each definition/relation/permission/caveat. Hover any symbol for its full explanation with a regenerate link. - New explain_schema assistant client tool (the model supplies the content; nothing is written into the schema). Explanations anchor to symbols by name via @authzed/spicedb-parser-js, re-position as you edit, and mark themselves stale when a symbol's body changes; regeneration is on-demand to control token spend. - Pure resolution/staleness layer, a persisted Zustand store, a Monaco decoration + view-zone renderer, and a dsl hover provider whose command trust is scoped to the regenerate command only. - Gated on AppConfig().aiEnabled; no structural backend change (client-side tool via the existing handoff path, plus guidance in PLAYGROUND_INSTRUCTIONS). Covered by unit tests (resolution, store, tool, trigger, helpers) and a Playwright renderer test. The live LLM round-trip is verified manually only.
josephschorr
force-pushed
the
feat/inline-schema-explanations
branch
from
September 17, 2026 20:21
ca2f13f to
d88f44b
Compare
Schema, Assertions, Expected and Relationships (code editor) render EditorDisplay at the same tree position, so React reused one instance and only swapped the Monaco model. EditorDisplay registers its editor under the item it was first mounted for, so when that wasn't Schema the annotation renderer found no editor for Schema and silently skipped rendering. Key each EditorDisplay by its document so a tab switch remounts it, as the grid path already did and as the pre-editor-groups layout did. Adds browser regression tests covering Full and Compact modes across tab round trips, including the case where the shared editor is first mounted for another tab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…lanations The explain_schema tool wrote its results with `input.show ?? "full"`, so turning on Compact and generating jumped the toggle to Full as soon as the explanations arrived. The model is never told about `show`, so the default always won. When explanations are already showing, keep the user's density; `show` (default Full) now only decides how to reveal them when they were hidden. Document that on the `show` parameter and add tests for each case. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Formatting only: re-wrap a few long statements and order imports, so that `npm run format:check` passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
samkim
approved these changes
Sep 21, 2026
This branch was successfully deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Adds an agent-driven Explain control to the schema editor that overlays AI-generated explanations inline in Monaco — without ever modifying the schema text. A tristate toggle (Off / Compact / Full) controls density; a Regenerate button re-runs the agent on demand.
Explanations are generated by a new
explain_schemaassistant client tool (the model supplies the content; nothing is written into the schema). They anchor to symbols by name via the SpiceDB parser, so they re-position as you edit and mark themselves stale (dimmed + ↻) when a symbol's body changes — regeneration is on-demand (never per-keystroke) to control token spend.Gated entirely on
AppConfig().aiEnabled.How it works
explain_schemaclient tool validates each symbol against the current parse, hashes its source for staleness, and writes a persisted Zustand store (useSchemaAnnotationStore).resolve.ts) maps symbol → Monaco range and computes staleness via@authzed/spicedb-parser-js(reads caveat ranges from the raw AST to work around a v1.2.0 wrapper bug).renderAnnotations.tspaintsafter-decoration tags (Compact) and view-zone blocks (Full / click-expanded), width-constrained and indented to line up with the code.EditorDisplay(schema editor only) with a once-registereddslhover provider; the hover'scommand:trust is scoped to the regenerate command only, so LLM-authored text can't smuggle other executable command links into a trusted tooltip.PLAYGROUND_INSTRUCTIONS; no structural backend change — the tool executes client-side via the existing tool-handoff path.Notable fixes made along the way
automaticLayout: false, so decorations/view-zones added after generation weren't flushed; a forcededitor.layout()on the next frame fixes it.Testing
explain_schematool (incl. unknown-symbol handling), the generation trigger, light-markdown rendering, and thereconcileGeneratingStatus/shouldGeneratehelpers.tsc --noEmitclean; oxlint clean aside from 2 pre-existingreact/only-export-componentswarnings on co-located, test-imported helpers.