Skip to content

Let a native chat pin a skill and a node, and open a play's Edit chat bound to it #3520

Closed

Description

@malibio

Overview

The play viewer's Edit opens a new native chat already set up for editing that play (ADR-090 §3–§5). Two things that don't exist yet make that work:

  • a chat that pins nodes;
  • routing that always offers a chat's pinned skills.

Today every turn routes from scratch. Nothing lets a chat start with a skill attached, or keep a node in view.

Proposed Solution

  • pins relationship on ai-chat-native: chat → any node, many, reverse pinned_in. Declared through the node-type sequence.

  • Routing: in a chat with pinned skills, each pinned skill is added to Stage 2's candidate block, with its instructions and schema_metadata, beside retrieval's top-K. It counts toward the offered set like any linked candidate.

  • Entity list: every pinned node that isn't a skill is always included, exempt from the recency cap, and re-read live before a tool acts on it.

  • Edit chat: the viewer's Edit creates a new ai-chat-native chat titled Edit <play title>, with:

    • pins to the play-authoring skill and the play;
    • an opening assistant message written by the system with no model call. Its content asks what to change and links the play, with outcome: clarified and options Change when it runs, Change a condition, Change an action, Add a rule, Remove a rule.

    It then opens the chat in its viewer.

Documentation

Architecture Impact

Implements ADR-090 §3–§5. That ADR amends ADR-038 and ADR-064 (pinned skills are always Stage-2 candidates) and ADR-088 (ai-chat-native declares pins). The docs are already updated (nodespace-docs 88cc64b).

Acceptance Criteria

  • ai-chat-native declares pins / pinned_in (target: any node); node-types:check passes; generated types committed if the wire changes
  • Routing:
    • in a chat with a pinned skill, every turn's Stage-2 candidate block includes it, with instructions and schema_metadata, beside retrieval's candidates (no duplicate when retrieval also finds it);
    • it counts toward the offered set;
    • a chat without pins routes exactly as before
  • Entity list: a pinned non-skill node is in every turn's entity list, exempt from the recency cap
  • Creating the Edit chat:
    • one backend operation creates the chat, its pins and its opening message;
    • no model call is made;
    • the opening message's link records a mentions edge from the message to the play, so the play's backlinks list it and lead to the chat
  • The opening card renders its options through the existing options rendering; picking one sends it as the user's turn
  • PlayNodeViewer's Edit button creates the chat and opens it (Add PlayNodeViewer: a play's rules as a read-only workflow, with its on/off switch and Edit #3518 hides Edit until this lands)
  • Tests:
    • routing with and without pins;
    • a pinned skill also found by retrieval;
    • the entity list keeps a pinned node past the cap;
    • Edit chat creation (pins, opening message fields, mention edge);
    • the routing and decisions evals don't regress
  • The prompt golden test is updated and reviewed if the assembled prompt changes
  • bun run quality:fix clean; bun run test:changed passes

Technical Specifications

Reference Files

  • Routing: packages/agent/src/local_agent/routing.rs (candidates, stage2_tools, offered set); the candidate block in packages/agent/src/local_agent/agent_loop.rs
  • Entity list and message history: packages/agent/src/local_agent/agent_loop.rs, packages/agent/src/local_agent/tools.rs (resolved_entities_from)
  • Core schemas: packages/core/src/models/core_schemas.rs (ai-chat-native)
  • Chat creation (frontend): packages/desktop-app/src/lib/stores/ai-chats.svelte.ts (createChat), services/ai-chat-default-model.ts
  • Options rendering: packages/desktop-app/src/lib/components/chat/chat-message.svelte

Implementation Details

  • The opening message is a normal ai-chat-message (role assistant), written by the system. The first model turn answers the user's reply to it, so turn assembly must treat it like any assistant message.
  • Pins are written only at creation in this issue. Pinning from the UI later is out of scope.

Dependencies

Related Issues

Non-Goals

  • Pinning or unpinning from the chat UI
  • Bound chats for node types other than play

Metadata

Metadata

Assignees

Labels

aibackendenhancementfrontend

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions