Repository navigation
feat(chat): let the person attach Chat's file to its task and mark it done, with Undo (W2-12) - #1902
Conversation
…ad a skill when Chat picks it (W2-04) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… skills (W2-04) The library is now the v2 mockup's Ansvisor skills, by the ids CHAT-21's agents use (winback, tasks, quality, faq, report, beat, refresh, publish, shopping, wrongclaim, answerfirst, facts, compare, translate), with the mockup's titles and card lines. Six reuse the earlier bodies; the nine earlier skills that map to none are removed. A message calls a skill by the /commands it starts with, so a page path like "/faq" later in the text isn't one, and the /report skill takes the /report shortcut's place in the / menu. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l name a skill writes (W2-04) - The scan also reads the front matter's values once parsed, so a double-quoted escape can't hide an instruction, hidden character, email or price. The reader keeps metadata without a prototype, needs a space after each colon and refuses tabs and mixed indents. - Every snake_case name in backticks must be one of Chat's tools. - report, facts and publish describe what Chat does: no email, approved facts only, a CMS draft. - A skill the model picks after the run read outside text isn't loaded; the person's /name still is. The prompt says a /name without a block wasn't loaded. - skills/README.md says how a Chat skill is added, and that outside skills come later through import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… (W2-04) On Chat Home the box sits high on the page, so the / menu with the fourteen skills ran past the header. The /, @ and + menus now pick their side as they open, and again when the window changes size: above when their rows fit between the box and the nearest clipping box (the page's scroll area under the header) or the window, else below when there's more room there. Their height is the room on that side less the gap, at most 300px, and the active row stays in view as the arrows move it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ding outside text (W2-04) A run started from a tainted run's next move starts tainted (fromTaintedMove): its message is that model's text, so a leading /name in it is the model's pick, not the person's. Such a run now loads no typed skill; the person's own /name in the same chat still loads.
…uplicates checked first (W2-10) CHAT-09 §E and CHAT-20 §12 (V1 Final rules), behind the web's Chat tools. - POST /api/action-center/chat-actions/check: the brand's active actions that already cover a finding's prompts, pages or competitors (their kept list, 00244, and the prompts and pages their payload names), closest first: all of it, or some. - POST /api/action-center/chat-actions: the finding as an action, kind chat_finding with payload.source chat, the chat, the run and execution.mode (assisted or automated). An action that covers it answers 409 duplicate with that action and whether Create anyway may go (only when the entities differ); the same idempotency key returns what it made. - Frozen at creation: every entity, the targets, the baseline (the basket's metrics over the 14 days before, each named prompt per named platform) and the approved tasks, checked against AC-004 (a page or place per task, Done when, no analyze/identify/validate/measure, no "for N prompts"). tasks_generated_at is set, so the task writer never rewrites them. - Manual: Chat's own dedup key takes no definition slot, and the generator leaves chat_finding out of the day's five. The engine scores it on creation (priority.js sentByHand) and validate.js measures it on its prompts and pages, as other person-sent kinds. - Admins and Managers of the brand only; both routes on the demo-brand list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tasks and set Ready for review, with Undo (W2-10)
CHAT-09 §D–E, CHAT-20 §9 rows 43–46, §10a–b, §12. Behind CHAT_AGENTIC.
Tools (lib/chat/registry/action-center-tools.ts, Admins and Managers,
policy Ask (auto allowed in Full auto)):
- create_action (Send to Action Center): its card lists the tasks; a
duplicate check runs before the card (a row's new `precheck`), so an
active action that covers it is said with no card, for Add to AC-{n};
Create anyway only where the entities differ. Undo 24 h while no task
started: the action is cancelled, in its History.
- attach_to_action (Add to AC-{n}): the finding as evidence in History;
the action's targets never change. Undo 24 h.
- attach_file_to_task (Attach only): chat_file_task_links, file attached,
History line. Undo 7 d. The model now gets the file id a change filed.
- set_task_ready_for_review: Chat's status in chat_task_state and a
History line; the task's own status doesn't change. Undo 7 d.
No tool completes, dismisses or edits a task or an action.
Chat: Send to Action Center under the latest answer (Admins, Managers, own
chat); approval cards list a change's items; a new action.sent event shows
"Sent to Action Center · AC-n" / "Added to AC-n" with Open in Actions
(/dashboard/action-center/actions/[id] redirects to its drawer), kept after
a reload; the place (chat, run, approval key, execution.mode) reaches the
write rows.
Action Center: "Attached from Chat" in a task's details (name, who, when,
Open) with a count on the task row; History lines for created from Chat,
attachments, findings, Ready for review and their Undo; kind chat_finding
with its title, finding, goal and a Source: Chat block.
Help: chat, action-tasks and action-center-actions updated.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… as any person's send (W2-10) The owner's decision of 2026-10-31: a Chat-created action counts toward the brand's daily five new actions like Improve's, Content's or Mentions' sends. Those are never refused or queued for it: they are made, and the nightly generator opens fewer of its own, the rest waiting in its queue. So: - generate.js counts chat_finding again (the exclusion is taken back), with a test that Chat's sends today leave the generator less room. - POST /api/action-center/chat-actions still always makes the action, and says the day's count (dailyLimit: used, limit, reached) after it. - createChatAction passes on daily_limit_reached and the one sentence Chat says then (chatEngine.actionCard.dailyLimit); create_action's description tells the model to say it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rver (W2-10)
Review follow-ups for Send to Action Center's route (CHAT-09 §E, CHAT-20 §12).
- S1: an action whose tasks can't be written is deleted again, so no action
is left without the tasks the person approved; the same approval tried
again makes it whole.
- S2: the duplicate check reads the competitors a payload names
(competitorIds, competitorId) beside the kept list.
- K3: the chat, the run and how it was approved are read again on the
server (verifiedPlace): the caller's own chat, a run of it, and its step
by the approval key, whose mark says automated. A caller's word alone is
never recorded; executionMode is null when it can't be read.
- K4: an approval whose action was cancelled or deleted since answers 409
conflict instead of "made".
- K5: the routes' 400s carry code invalid.
- K9: a bare word ("pricing", "blog/aeo") is a path on the brand's site,
never a host.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… and the Action Center drawer (W2-10)
- B1: Send to Action Center sends the answer's run (fromRunId). The server
reads that run's taint, as for a next move; a run that isn't this chat's,
or an unreadable one, counts as tainted. A change written from an answer
that read outside text shows its card even in Full auto (§16a rule 3).
- S3: create_anyway shows its card in every mode, Full auto included
(alwaysCardWhen, read as overBatch by the precedence): that choice is the
person's (CHAT-09 18a).
- S4: the card shows what is frozen once made: each task with its new text
(shortened, Show all), the finding (why), the goal and the targets
(prompts, pages, competitors, platforms). cardDetails replaces cardItems;
ApprovalCard takes children; copy in chatRun.proposal.
- S5: Undo of a sent action only dismisses it (no deleted_at), so it stays
in Dismissed, with "Cancelled from Chat by {user} · undo" in History; any
event but created since (assigned, edited, a task added, a finding or a
file attached) answers changed.
- S6: conflict is a said refusal: a closed action's or task's words reach
the model.
- K1: a file's title on the card is read within the brand's workspace.
- K3: the server action reads the chat, run and step itself (the step the
engine marks when it ran without a card) and records nothing a caller
only said; Ready for review refuses a task of another brand than its
chat's.
- K5: 403 not_in_workspace / no_brand_access and 409 conflict are said as
such.
- K6: the paperclip says "{n} files attached from Chat" to screen readers.
- K7: unique keys; Open the chat only for a reader who may open it.
- K8: actions/[id] opens the drawer on the action's brand with no filter.
- K10: a finding's note and sources show in History; a withdrawn one says
which finding.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # web/src/lib/chat/engine.test.ts
… in a task strip under the answer (W2-11)
CHAT-09 §B, CHAT-08 Complete tasks, mockup #s-work / #s-done; behind
CHAT_AGENTIC, no migration (chat_task_state, 00418).
- task-strip.ts: a /tasks run queues the week's tasks, at most 4, due
first and by Priority Score; opening an action (get_action) marks its
tasks Writing; Ready for review comes from W2-10; the run's end settles
Writing back to Queued. Done is read from the Action Center only.
- The engine keeps the strip from its reads, only in a run that loaded the
/tasks skill, and never fails the run over it; `tasks.updated` carries
the whole strip, with no ids.
- The answer shows "Action Center tasks · N due", "X of N ready" and a row
per task ("Priority 86 · Fix", Queued / Writing / Ready for review /
Done), and once the run ended "Close tasks in Action Center". A reload
rebuilds it from chat_task_state as the person may see it.
- Complete with Chat sends /tasks; the /tasks skill sets Ready for review
and helps with open Getting started steps, never marking one done.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A task with no title is worded from its key in en.json (taskText); a key en.json doesn't word now reads "An Action Center task" instead of the message path next-intl falls back to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s card, with Undo (W2-12)
CHAT-09 items 12–16; no migration (chat_file_task_links 00411,
chat_task_state.file_id 00418).
- A /tasks run's deliverable is tied to its task only when that is
certain: the one task Chat is writing of the action it opened last
(get_action), a page draft breaking a tie; else no "Task:" line.
- Its card says "Task: {title}"; Admins and Managers get Attach to task &
mark done and, in ⋯, Attach only. The card names its file by its run and
place; the run must be of the person's own chat.
- Mark done links the file, sets it done and completes the task through
the Action Center's own write (task-status.ts, shared with the drawer's
updateTaskStatus): the person is the actor, Chat the source in History.
Its toast's Undo puts the task, the file and the link back within the
hour, and says changed once the task, its action or its History moved.
- A reload brings each deliverable's task back; the strip shows Done.
- No model tool closes a task.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolves help/chat/chat.md keywords, thread.ts imports and thread.test.ts against the squashed ansvisor#1897/ansvisor#1900 on main.
…rk done or its Undo (W2-12)
- markTaskDoneFromCard and undoTaskDoneFromCard call can_access_brand on the task's brand, as W2-10's writes do, and refuse a file of another brand (not_found).
- assertWritable({ brandId }) runs before the first write, so a demo brand leaves no link or done file behind.
- A skipped task's why goes in the mark done's event; Undo puts it back.
- The test's person client answers can_access_brand (main's attachFileToTask now calls it).
gkhngyk
left a comment
There was a problem hiding this comment.
Approving, with 2 commits on top: commit f06a4b7 merges main in, and commit 7fc1204 fixes the card's server actions.
Merge (f06a4b7). Main now has #1897 and #1900 squashed, so the stack's history conflicts. The merge keeps main's versions of everything from W2-10 and W2-11, and puts only this PR's last commit on top. Three files needed hand fixes:
help/chat/chat.md: main's keywords plus the three new ones.thread.ts: thewhy/*imports kept next toreadDeliverableTasks.thread.test.ts: both new tests kept.
The card test's person client also needed rpc. Without it, the Attach only tests fail on main, because attachFileToTask now checks can_access_brand.
Fix (7fc1204), chat-task-card.ts
markTaskDoneFromCardandundoTaskDoneFromCardnow callcan_access_brandon the task's brand, as W2-10's Chat writes do. They also refuse a file whose brand isn't the task's, asattachFileToTaskdoes. Both cases answernot_foundand write nothing.assertWritable({ brandId })now runs after the card is read and before the first write. Before, only the plan was checked, so on a demo brand the link and the file'sdonewere written before the database refused the task update.- When the task was Skipped, its reason now goes in the mark-done event, and Undo puts it back. Before, Undo returned the task to Skipped with no reason.
- Each fix has a test that fails without it.
Checked, fine as is
- Admin/Manager is checked on the server on every click, and the plan check is still each action's first await (
subscription-guard-coveragepasses). manager_execute_offcovers only go-live groups, so a mark done doesn't count.- The
action_tasks → actionsembed namesaction_tasks_action_id_fkey, the only FK. - Completing a task doesn't change the action's status and has no task-level triggers on prod, so Undo leaves no completion, measurement or ledger state behind.
- On reload the strip and the card read
action_tasks.status, so they show Done or Open correctly. - en.json keys all exist.
- The help section is within the limit, and the article stays
approved: false.
Follow-ups (not blocking)
- Attach only calls
attachFileToTaskwithout a place, so its History event has no conversation or run. Mark done records both. - Two clicks that land together can both read the task as open and write two events. The button is disabled while busy, so this is a narrow window. A conditional update (
.neq('status', 'completed')) would close it. - The PR body names
lib/actions/chat-task-done.ts. The file ischat-task-card.ts.
Tests: web vitest on src/lib/chat, src/components/chat, action-center, actions, guards, subscription-guard-coverage, demo-gate-routes, help and plan-row. 3,085 tests: all pass, except the two known timing tests, which pass when run alone. tsc --noEmit, eslint and prettier are clean on the touched files.
gkhngyk
left a comment
There was a problem hiding this comment.
Merging in order with the other approved PRs. This head merges current main; its tree is what main will be after this squash, checked with the full server and web suites, tsc, lint, format and next build.
…click repeats (#1935) Follow-ups from the approval notes on #1897, #1902 and #1898. - Add to AC-{n} (attachToAction, W2-10): the evidence_attached event carries its approval's key (`chat:{step}`, as Send to Action Center's payload does), and a retried approval finds that event and returns it instead of adding the finding again. Two calls at the very same moment are already kept apart by the engine's idempotency claim; a database-level guarantee would need a unique index (a migration), not added here. - Card clicks (W2-12): Attach to task & mark done and its Undo write the task's status only when it really changes (`.neq('status', …)` through writeTaskStatus's new onlyIfChanged), so two clicks at once leave one History event. The drawer's own writes are unchanged. - Attach only from a card now records the card's chat and run on its file_attached event, as a mark done's event does. attachFileToTask takes the card's place and reads it on the server (the person's own chat and a run of it) before recording it; no execution mode, as it is the person's own click. - Daily suggestions (W2-26): recordUse skips a removed suggestion (no use, no feed stamp), and the page's last Site Audit matches the action's pages by pageKey (no scheme, www or trailing slash), by the audit's url or final_url, among the brand's latest 500 audits (as the server's recheck reads them). - The test fake reads JSON-path filters (`data->>key`) as PostgREST does. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Chat W2-12 lets the person attach a file Chat made to its Action Center task and mark the task done, in one click, as themselves (CHAT-09 items 12–13 and 16, mockup
CHAT-mockup-v2.html#s-done). Stacked on #1900 (W2-11); review only the last commit. Everything stays behindCHAT_AGENTIC/CHAT_AGENTIC_ORGS. No migration:chat_file_task_linksandchat_files.status(00411) andchat_task_state.file_id(00418) already exist.Chat never closes a task itself. No model tool can. The task is closed only by the person's click, through the same write the Action Center drawer uses.
Which task a file belongs to (engine)
/tasksrun files a deliverable, it goes onchat_task_state.file_idof a task the run is writing. The candidates are open tasks of the action the run last read (get_action) that have no file yet.chat_task_state.file_idor its single link.Server actions (
lib/actions/chat-task-done.ts), the person's click onlyThe file is found by
(runId, n); no id reaches the browser. A run that isn't the person's own, live chat answersnot_found.The refusals:
forbidden;read_only, and the card opens the plan dialog;closed.The plan check is each action's first await.
attachAndMarkDone:attached_by= the person) and marks the filedone;logEvent,touchActionand a newwriteTaskStatusmove tolib/action-center/task-status.ts, andupdateTaskStatusnow calls it, with the same behaviour.source: 'chat', the conversation and the run.attachOnlycalls W2-10's attach as the person. The file becomesattached, and the task stays open.Undo (toast "Task marked done in Action Center"):
via: 'undo'.changedand changes nothing.Card (
DeliverableCard)Help:
help/chat/chat.mdgets "Close a task from what Chat made" (approved: false).Note: Action Center tasks count as text from outside (CHAT-20 §16a, generated tasks). So a
/tasksdraft afterget_actionasks for a card even in Full auto, as since W2-11.Related issue
None. Chat Wave 2 (W2-12).
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
CHAT_AGENTIC=true. Run/taskson a brand with an open task Chat can draft for.chat-task-done(roles, read-only, closed action, every Undo case);file_idhook (one task, the draft tie-break, two candidates, an action not read, another run);thread, the card,task-status, and the Action Center drawer tests.Checked in the browser at 1024px, light and dark: a card with a task, a done card, a card with no task, and the ⋯ menu. The user approved the screens. Screenshots are available on request.
Checklist
yarn lintpasses (0 errors; 7 old warnings in files this PR doesn't touch)yarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)On this branch (aeda08a):
format:checkandtypecheckpass, and lint has 0 errors. 765 files / 7,802 tests: 7,801 pass. The one failure is the date-dependentchat-menu.test.tsx"Done · 08:02" case; fix(chat): give a chat row the menu's clock, so a run's time matches its day #1876 fixes it and is now on main.yarn buildpasses.format:checkand lint are clean, and 335 files / 4,618 tests pass (3 skipped).🤖 Generated with Claude Code