Repository navigation
Backlog
Backlog
Copy link
Labels
Milestone
Description
Goal
A provider can show what it is doing in the chat (for example "reading file X", "plan updated") and can ask the user for a yes/no-style decision in the chat while its answer is streaming. The chat turn passes the decision back to the provider. Nothing a provider shows or asks executes anything by itself.
Context
AiEvent(crates/core/src/ai/types.rs) hasWebActivityas the only informational event from a provider. It is handled incrates/app-logic/src/orchestration/chat_turn.rs:857/handle_web_activity(:982).- The chat turn already has a confirmation flow for proposed actions (
crates/app-logic/src/orchestration/pending_confirmation.rs,confirmation.rs) and an AskUser path (chat_turn.rs:740). There is no way for a provider to ask the user something and get the answer back during the same stream. AiProvider(crates/core/src/ai/provider.rs:24) hassend,disable_web_researchandlast_request_id, and no channel back from the app to a running stream.- Spec 0039 (untrusted content), ADR 0141 (fencing of extension content).
Requirements
- Activity event. A new
AiEventvariant for provider activity, e.g.ProviderActivity { id, kind, title, detail, status }.kindis a closed list: tool, plan, thought, notice.statusis pending, running, completed or failed.- A later event with the same
idupdates the entry. - It is informational only, like
WebActivity: it triggers no filter engine, no follow-up round and no execution. - The chat turn forwards it to the frontend and stores it in the chat history so it shows again after reload.
- It is never sent back to any provider as model input.
- Titles and details are untrusted text: length-limited and redacted with the session's output redactor before display and storage.
- Confirmation event. A new
AiEventvariant for a provider confirmation, e.g.ConfirmationRequested { request_id, title, detail, options }.- Each option has an id, a label and a kind from a closed list: allow once, allow for this chat, reject.
- The chat turn shows it in the chat as a confirmation the user answers.
- The answer goes back to the provider through a new trait method, e.g.
AiProvider::resolve_confirmation(request_id, ConfirmationOutcome), with a no-op default. - The outcome is the chosen option id, or
Cancelledwhen the turn is stopped, the session closes, the stream ends or the request is unknown. Unanswered means rejected.
- Effect on existing confirmations. A provider confirmation never changes how proposed actions are filtered or confirmed. It is not an
ActionProposedand never passes or affectsFilterEngine::evaluate(). - Built-in providers. They emit neither event. Their behaviour is unchanged.
- Spec. Spec 0006 (events) describes both events and the outcome rules.
Acceptance Criteria
- A test provider emitting
ProviderActivitywith two updates of one id results in one stored, updated activity entry, no follow-up round and no execution. - Activity text containing a known secret of the session is stored and forwarded redacted (test). Over-long text is truncated.
- A test provider emitting
ConfirmationRequestedreceives exactly the option the (test) user chose throughresolve_confirmation. - Stopping the turn, closing the session or dropping the stream while a provider confirmation is open resolves it as
Cancelled(one test each). - An unknown
request_idanswer is ignored and logged without panicking. - A proposed command in the same response still goes through filter engine and confirmation unchanged (test with both events in one stream).
- Existing chat-turn tests pass unchanged.
- Relevant automated tests pass.
Technical Notes
- Security-critical area: the chat turn and the confirmation path. The provider's text is untrusted (Spec 0039). Show it as plain text, never as markdown links or HTML, and never as an instruction to the model.
- The frontend rendering is a separate issue. This issue defines and emits the IPC events and the answer command, and regenerates
generated/ipc.ts. AiEventderivesClone, PartialEq, so the reply path cannot be a channel inside the event. Hence the trait method.
Files: crates/core/src/ai/types.rs, crates/core/src/ai/provider.rs, crates/app-logic/src/orchestration/chat_turn.rs, crates/app-logic/src/orchestration/ (new module for provider confirmations), crates/app-shell/src/commands/, crates/persistence-sqlite/ (only if chat history storage needs a new entry kind), apps/smart-ssh-community/frontend/src/generated/ipc.ts, docs/specs/0006-ai-provider-trait.md
Spec impact: update 0006
Open questions
- Storage of activity entries: (a) as a new message content variant in the chat history, (b) in the same place as
WebActivityentries. Recommendation: (b) ifWebActivitystorage can be generalised without a migration, otherwise (a).
Related Work
- Epic: Epic: AI provider kinds contributed by the embedding application #1636
- Blocked by AI requests carry their purpose and the saved chat session id #1638 (both change
crates/core/src/ai/types.rsandchat_turn.rs)
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
P2 - Normal
Activity