Repository navigation
feat(chat): show a run's work live under its answer (W1-14) - #1833
Conversation
…iles, Help and add-on packs Chat's Wave 1 tables in one PR (one DB PR per wave), behind CHAT_AGENTIC: nothing reads or writes them while the flag is off. Tables, types and the demo's coverage only; the code that uses them comes in the Wave 1 PRs. - 00407: chat_conversations gets shared_at (Share with team: every member of the workspace reads it), last_read_at (unread results), deleted_at (Delete with Undo; deleted chats are hidden from every member) and a title search column; chat_messages gets context_json (what a person's message was scoped to) and a text search column. 'simple' text search, so a chat in any language is found. The author policy now leaves deleted chats out, and a shared policy reads shared ones. - 00408: chat_user_prefs gets the rest of Settings › General and the one-time notices: rail_open, panel_size, default_mode, answer_language, notify_via, show_thought, panel_on_pages, focus_prompted_at, usage_notice_period, legacy_imported_at. - 00409: chat_uploads and the private bucket chat-uploads: 10 MB a file, the composer's 11 types, 5 a message (a trigger backs the server's check), kept 90 days. - 00410: chat_tool_cache (a chat's read results by tool and scope, server only) and each step's and model call's measure: latency, cache hit, truncation, result tokens on chat_run_steps (never granted to members), prompt cache read/write tokens and latency on the ledger. - 00411: chat_files (filed deliverables and saved answers, the workspace's, kept a year, searchable by title, summary and tags), chat_file_task_links, chat_storage_usage kept by a trigger, and the private bucket chat-files. - 00412: help_answer_cache and help_gaps (server only, no workspace or person ids). - 00413: add_on_products seeded with the owner's packs (AI credits $10, $50, $250, $1,000 at half their price in budget, 12 months; storage +25/+100/+250 GB at $5/$15/$29 a month; $50 and +25 GB Most picked), add_on_purchases (Admins read), ai_credit_grants and storage_grants (server only), and prompt_improve_usage.grant_id. Members only ever read; every write is the server's. Tool names, tool results and dollars stay server only. web/src/types/supabase.ts carries the new tables and columns; schema.test.ts checks the policies, the server-only tables, the limits and the seeded packs from the SQL; steps.test.ts keeps the step measure out of the member columns. The demo coverage skips chat_files and chat_tool_cache (a person's own Chat work). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and a read-only view Chat Wave 1, W1-10 (CHAT-02, agentic update). A copy of the mockup's composer (compHTML), as components to be wired into the Chat pages by the shell (W1-01). - ChatComposer: the box, a toolbar with the run mode and Send, and the line under it. Variants: home (2 rows), dock and panel (1 row). The box grows to 240px, then scrolls. - Enter sends, Shift+Enter adds a line. Enter during an input method's composition or on a touch screen is the box's own (composerKeyAction). Send is off for an empty box. - While a run answers, Send is Stop, and Esc stops too. The box steers: "Steer while I work…". Enter stops the run, its done steps kept, and sends the text as the next message (onSteer; decided 2026-10-30). The line under reads "Enter stops this run and sends your message". A page without steering keeps the text until the run ends. - ModeSwitch: Ask me first · Auto, ask before changes · Full auto, each pick with the mockup's toast. Full auto below Growth is locked: "Needs Growth", and it can't be picked. - Analysts and Agency partners read only: no mode switch, a "Read-only · Analyst" link to Your access, and "@ data · read-only" under the box. - The model button reads "Auto · Haiku reads, Sonnet writes". Slots for the + / @ tools (W1-12) and the usage meter (W1-23). - The Chat pieces preview gets a Composer section: home, a dock with a pretend run, and an Analyst's panel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…poser
Chat Wave 1, W1-11 (CHAT-02 items 5–10c), on the composer (W1-10).
- Context chips above the text: what Chat looks at, by name ("Ansvisor",
"Last 30 days"), never an ID. A label over 28 characters is cut, with the
whole name in its tooltip. × asks the page to drop it for the chat
(onRemoveChip). A send or a steer carries the chips left
(onSend(text, { context })).
- One ghost suggestion in the empty box, dim, with a Tab key hint. Tab, or a
click on it, makes it the text with the cursor after it. Typing replaces
it, and it comes back when the box is empty again. It never sends by
itself: while only it shows, Enter does nothing and Send stays off. With
text, Tab moves on as usual. No ghost while a run answers. The page picks
the suggestion: the variant's starter, then a clear follow-up, and a READ
one for Analysts and Agency partners.
- The line under reads "Tab to accept · / skills · @ data" while the ghost
shows.
- The preview's composers get the mockup's chips and starters.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Chat Wave 1, W1-12 (CHAT-02 items 11–17, agentic update; mockup #slash,
#atmenu, #plusmenu), on the composer's chips (W1-11). Menus open above the
box: ↑ ↓ move, Enter picks, Esc closes and keeps the text, and a click
outside closes them.
- /: typed first in an empty box, or from the / button. It lists Wave 1's
shortcuts, which start a message: /analyze "Analyze", /report "Create a
report on", /create "Create content for". Typing filters them by command
or a word of the name. From the button, the box's text stays after the
starter. Analysts and Agency partners have no / (as the mockup). Skills
join the menu in Wave 2.
- @: typed at the start of a word, or from the @ button at the cursor. It
references data: the page's own charts and metrics first (references,
for W1-08), then the brand's matches (searchReferences), up to eight. A
pick leaves the "@…" text and shows as a chip by name. × takes it off,
and the send carries it (references: type, id, label, scope). No ID
shows.
- searchChatReferences (server action, CHAT_AGENTIC): the brand's tracked
prompts, its pages and its open Action Center tasks that match, a source
at a time. Read with the person's session; site_pages isn't in the
generated types, so it is read with the service role for a brand the
session can read. Template tasks are named from their keys. A search is
made safe for PostgREST's filters. It answers { ok, failure } and never
throws (ansvisor#1777).
- +: Attach files when the page uploads (onAttach, W1-13). Connect a tool:
Settings › Integrations for an Admin; for others, "Ask your Admin to
connect" sends one access request (B2). Read a page and Create an image
stay hidden until their waves.
- The preview's composers reference the mockup's chart, metric, table,
page and task.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Data used and its stamp Chat Wave 1, W1-14 (CHAT-03 items 12a–14, the v2 timestamps), on the composer's menus (W1-12). RunAnswer draws an answer from its run's events, with the shared pieces (D1/D2): - The agent works beside it (AgentAvatar), waits on the person, or is still. - One status line, updated in place, in the running step's words: "Reading Citations…", "Opening ansvisor.com/pricing…", "Checking facts…". With no step running, "Writing the answer…" while text streams, else "Thinking…". "Reconnecting…" when the stream dropped. - The steps under their header (RunSteps). Each step done, thinking left out, is a ✓ chip with its rows, and a click shows its detail. W1-21's "Checked facts" step (ansvisor#1822) is one of them. - The answer streams in (Markdown). - "Data used": one chip per source a read step read, with its largest row count, and per page a step opened. Skills, thinking, checks and failed reads are no source. The header counts these chips as its sources. - "Generated Oct 30, 2026 · 09:14 · Data as of …" in the person's time zone, the GMT offset in its tooltip. - What follows (next moves, the answer's actions) fades in once the run is done, and not at all with reduced motion. - run-view.ts holds the status line, chips and Data used, from the steps alone. - The Chat pieces preview plays the mockup's answer a step at a time ("Live answer"); its counts take the new pieces in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The × button unmounts with its chip, so a keyboard user lost their place (focus fell to the page body). Focus the message box after removing a chip. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
# Conflicts: # web/src/components/chat/composer/chat-composer.tsx
PostgREST reads * as % in like and ilike, so "@price*list" matched anything between the two words. Strip it with the other pattern characters. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
…nswer A read step whose words aren't "Read …" (the app's own "Opened a page" from the page router) read no source: it no longer shows as a Data used chip or as "Reading Opened a page…". The answer's Markdown links only http(s) addresses (in a new tab) and pages of the app, and shows an image as its alt text. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with 80f565e: this PR, a merge of #1828's new head (with #1827's fix), and one fix commit, described below.
Fixes
1. A read step that isn't "Read …" shows up as a data source. The engine records every read-class tool as a kind: 'read' step. Its label comes from chatTools.<key>.step. #1807 (approved) adds the open_page navigation tool, whose step label is "Opened a page", and that tool is also a read. With this PR as written, that step would show:
- a status line of "Reading Opened a page…", and
- a "Data used" chip "Opened a page", which also counts as a source in the header.
The fallback label "Worked on a step" has the same problem. readSource now returns null when the label doesn't start with "Read ". In that case the status line uses the step's own words (other), and the step isn't counted as a source:
export const readSource = (label: string): string | null =>
READ.test(label) ? label.replace(READ, '') : null;A note on naming: the step kind open_page (CHAT-03: a step that opened a web page, shown as "Opened ansvisor.com/pricing") and #1807's tool open_page (go to a page of the app, with labelKey goToPage) share a name but mean different things. Nothing breaks today, because the engine never emits the open_page kind. To keep the two apart later, it might be worth naming #1807's tool after its label key (go_to_page) before it merges.
2. Links in the answer. The answer text goes through the shared Markdown component, which by default also links mailto:, xmpp:, irc: and relative addresses, and loads images. RunAnswer now passes its own a and img:
- http(s) links open in a new tab with
rel="noopener noreferrer nofollow". /dashboard/…paths are linked in place.- Any other address shows as plain text.
- An image shows as its alt text.
For this, markdown.tsx exports its default components as MARKDOWN_COMPONENTS, so code blocks render the same as before.
Also: the "Data used" chips used chip.label as their React key, which could repeat if a page and a source ever had the same words. The key now includes the chip's index.
Base
This branch sits on #1828's old head (db78ca6e4). #1827 and #1828 now each have one more commit (focus stays in the composer when a chip is removed; * in the @ search). Merging #1828's current head (602a4e2ef, which contains #1827's) into this PR is clean. take-1833 includes that merge.
What we checked
- Rendering: step labels, details, rows and Data used chips are plain text nodes. Nothing is set as HTML. The status values go through next-intl as values, not as messages.
- Live stream: this PR adds no stream code. RunAnswer is fed a
ClientRun(main'srun-state.ts) and areconnectingflag from its caller, so ownership checks,after/Last-Event-IDand reconnect behaviour are reviewed where the stream is opened, not here. - Status line: there is one
aria-live="polite"line, updated in place and only while the run works (or reconnects). It isn't per step or per token, so it shouldn't be chatty. The streamed text isn't in a live region. Optional: since the region is only mounted while the run works, a screen reader doesn't hear the run finish. A short "Done" before it unmounts could help, but this isn't blocking. - Long runs: chips and Data used are derived from
run.stepson each render (sort + Map), and nothing is kept beyond the run. That's fine at Chat's step limits. - Motion: the footer fades in only with
motion-safe, and only once the run isdone. - No migrations, routes or server code in this PR.
steps.ts/steps.test.tsshow in the PR's file list only because of #1812 below it.
Tests
Run on take-1833 (PR + #1828's new head + the fix):
run-view.test.tsandrun-answer.test.tsx: the two new tests fail without the fix and pass with it.- Chat, agentic and Chat preview tests, plus
lib/guards/plan-row.test.ts: 36 files, 555 tests passing. tsc --noEmit, plus eslint and prettier on the changed files: clean.- Merges cleanly with current main (main is already in the stack) and with #1807 and #1835.
…ew fix) into take-1835
…svisor#1833 and ansvisor#1834 fixes) into take-1843 # Conflicts: # web/src/app/[locale]/(dashboard)/dashboard/chat/_chat-page-access.test.ts # web/src/app/[locale]/(dashboard)/dashboard/chat/_chat-page-access.ts # web/src/components/chat/chat-thread-view.tsx # web/src/components/chat/composer/chat-composer.test.tsx
gkhngyk
left a comment
There was a problem hiding this comment.
Merging in order with the other approved Chat PRs. This head merges current main; where they overlapped, both sides are kept. Its tree is what main will be after this squash, checked with the full server and web suites, tsc, lint, format and next build. Chat stays behind CHAT_AGENTIC.
Summary
Chat Wave 1, W1-14: show the work live under an answer (CHAT-03), behind
CHAT_AGENTIC. Stacked on #1828 (W1-12). The diff against main includes the PRs below it until they merge. The product owner saw it in the preview's Live answer player and approved it.What it adds
components/chat/run/run-answer.tsx(RunAnswer) draws an answer only from the run's events (ClientRun), reusing D1/D2's parts.aria-liveline, updated in place in the running step's own words: "Reading Citations…", "Opening ansvisor.com/pricing…", "Checking facts…". With no step it reads "Writing the answer…" while text streams, else "Thinking…". A dropped connection reads "Reconnecting…".RunSteps). Each finished step except thinking becomes a ✓ chip with its row count, opening its detail on click. That includes W1-21's Checked facts (feat(chat): check every figure in an answer against the run's data (W1-21) #1822, step kindcheck; no engine change).footer(next moves, answer actions) appears only when the run is done. With reduced motion there's no animation.cards: approval and refusal cards go under the answer.components/chat/run/run-view.ts:statusLine,doneStepsanddataUsed, pure and unit-tested.No migration, no new dependency.
Related issue
Part of Chat (CHAT-03, Wave 1).
Type of change
feat— New featureHow to test
/dashboard/chat/preview› Live answer › Play. Tests:src/components/chat/runand the preview (63 tests).Checklist
🤖 Generated with Claude Code