Skip to content

feat(canvas): add creation slash command - #767

Merged
Neonforge98 merged 9 commits into
developfrom
junyu/canvas-slash-command
Aug 14, 2026
Merged

feat(canvas): add creation slash command#767
Neonforge98 merged 9 commits into
developfrom
junyu/canvas-slash-command

Conversation

@beruro

@beruro beruro commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

Canvas creation has no first-class composer command. Users must describe the desired UI indirectly, and the inline slash menu and pinned-action surface do not share a Canvas entry. A generic skill pill also gives the Agent no deterministic signal that this is a new Canvas creation request, so bare commands and lookalike text can be handled inconsistently.

Solution

Register /canvas in one shared built-in command list used by the in-session composer, Session Creator, and pinned-action picker. Both selection paths insert the same atomic command pill, with a Canvas-specific icon in the editor and sent-message history.

At the submit boundary, preserve the serialized pill as the visible/persisted user message while projecting only exact /canvas [request] commands into an Agent-only creation contract. An instructed command requires one render_inline_canvas call for a new Canvas; a bare command asks for requirements without calling the tool. Ordinary prose and lookalike commands remain unchanged. The command description is localized in all existing session locales.

Potential risks

  • Creation still depends on the selected Agent exposing render_inline_canvas; this PR does not add or change backend tool availability.
  • The Agent-side projection intentionally runs only where enableAgentInterceptors is enabled. Opt-out behavior is covered so specialized composers retain their existing dispatch contract.
  • A packaged Tauri end-to-end run was not performed in the isolated worktree. Rendered component tests cover pill insertion and both icon surfaces, but native session/tool dispatch remains an unverified manual path.
  • There are no persistence, schema, public IPC, or wire-format changes. Rollback is the single commit in this PR; existing messages and Canvas data require no migration or cleanup.

Architecture audit

Covered all 10 audit layers:

  1. Compilation: final TypeScript check passed.
  2. Liveness: every new production helper is wired into a composer or submit path.
  3. Types: the command is represented by SLASH_ACTIONS.CANVAS; helper-only option types remain private.
  4. Naming: Canvas creation is kept distinct from Canvas preview and revision concepts.
  5. Control flow: parsing is start- and end-anchored; ordinary prose and lookalikes are rejected.
  6. Boundaries: shared command registration/insertion is generic; the Canvas Agent contract stays at the submit boundary.
  7. Domain vocabulary: displayText, agentBase, and agentContent make the two projections explicit.
  8. Serialization: the persisted user message is unchanged; no backend wire schema changes.
  9. Initialization parity: ChatPanel and Session Creator consume the same registry and insertion helper.
  10. Resolution: no new multi-field fallback resolver or canonical-ID logic was introduced.

Effects: none added or materially modified. No timers, polling, subscriptions, workers, caches, or retained background resources were added.

UI audit

Report: docs/frontend-ui-audit-2026-08-10/CanvasSlashCommand.md

  • Fix: 0
  • Keep with reason: 6
  • Abstract: 0
  • Sweep candidates: none

No screenshot is attached because the isolated worktree was not launched as a signed desktop build. The changed states are covered with rendered jsdom tests for pinned insertion, editable pill rendering, and sent-message rendering.

Verification

Passed:

  • eslint on the 18 changed TypeScript/TSX production and test files.
  • vitest run on the seven Canvas command, projection, insertion, pinned-action, composer-pill, and sent-message test files: 7 files, 17 tests passed.
  • for f in src/i18n/locales/*/sessions.json; do python3 -m json.tool "$f" >/dev/null || exit 1; done
  • tsc --noEmit --pretty false
  • git diff --check
  • Staged-diff scan for secrets, personal paths, debug statements, build output, and unrelated files: no findings.

Not run:

  • Full Vitest suite; the focused behavioral set covers the changed lifecycle, and the final full-repository check was limited to TypeScript as agreed to avoid repeated whole-repository scans.
  • Packaged Tauri manual test; native tool dispatch is the remaining verification risk described above.

@beruro
beruro requested a review from Harry19081 August 10, 2026 10:19
Harry19081 and others added 8 commits August 11, 2026 00:09
- shared projectOutgoingUserMessage used by submit, edit-resend, queue
  edit, external-history fork, group chat, and session-creator launch;
  the agent contract can no longer leak into visible messages nor be
  silently dropped
- canvas pill recognized anywhere in the draft (parity with compact);
  typed /canvas stays start-anchored
- canvas builtin hidden and projection disabled for CLI sessions and
  image-attached messages; ChannelComposer menu filtered like
  HumanSessionView
- builtin names reserved against same-named user skills; slash-items
  cache keyed by builtin set; pinned creation action labeled New Canvas;
  canvas arg ghost hint wired

(cherry picked from commit fa591d21769fc7f6ba9cdb1824347ad3c2b675bc)
…parately

Pre-commit hook ran. Total eslint: 18, total circular: 0
767-scoped subset of audit commit 10e5273706 (the rest of that commit
is canvas-app material that rides with PR 709):
- pinned canvas CREATION action labeled New Canvas so it cannot read as
  a duplicate of the Canvas preview-reopen button
- canvas action not offered for pinning in CLI sessions (no
  render_inline_canvas tool there); stale non-atomic pin fallback removed
- queue edit seeds the editor from the DISPLAY copy, never the agent
  projection (msg.content now carries the agent contract)
Channels opt out of agent interceptors, so agent-only built-ins
(canvas, compact) must not appear in the "/" menu — same skill-only
filter the Work Log composer uses. 767-scoped piece of audit commit
cc0a56b837.
767-scoped subset of audit commit cc0a56b837:
- input.canvasArgHint and input.newCanvasAction added to all 13 locales
- zh/zh-Hant compact/canvas input keys normalized to full-width colon

Excluded (ride with PRs 709/768): canvasApp.*, tools.reviseInlineCanvas*,
domSelection, manageIssues.
@Neonforge98
Neonforge98 merged commit 1e29929 into develop Aug 14, 2026
3 checks passed
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.

3 participants