Skip to content

feat(chat): work through this week's Action Center tasks with /tasks, in a task strip under the answer (W2-11) - #1900

Merged
gkhngyk merged 17 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-11-task-strip
Oct 31, 2026
Merged

gkhngyk merged 17 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-11-task-strip

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat W2-11: /tasks works through this week's Action Center tasks. A task strip under the answer shows each task's state while Chat drafts the work (CHAT-09 task strip, CHAT-08 "Complete tasks", CHAT-13 /tasks, mockup CHAT-mockup-v2.html#s-work and #s-done).

Stacked on #1897 (W2-10), with #1885 (W2-04 skills, now on main) merged in. Review only the last two commits: the strip, and a fix so a task never shows a raw key. Everything stays behind CHAT_AGENTIC / CHAT_AGENTIC_ORGS. No migration: chat_task_state (00418) already holds the strip.

Server (web/src/lib/chat/task-strip.ts)

  • pickTasks picks the open tasks of open actions, at most 4:
    • due this week first, by the person's own week end (Sunday in their zone);
    • then by Priority Score;
    • undated ones only if room is left.
  • queueTasks puts tasks on the strip as Queued. A task already on it keeps its state and place.
  • startAction marks an action's tasks Writing once Chat reads it (get_action).
  • settleStrip turns Writing back to Queued when the run ends: normally, on an error, or on Stop.
  • readStrips reads the strip back. Done comes only from the task being completed in Action Center; Chat never writes it.

Engine: the hooks run only while the tasks skill is loaded.

  • After list_action_center_tasks: tasks are queued.
  • After get_action: that action's tasks are Writing.
  • After set_task_ready_for_review (W2-10), and at the end of the run: the strip is sent again as tasks.updated.
  • No new model tool.
  • The event: tasks.updated = { tasks: [{ at, title, priority, category, status, due? }], ready, total, due }. It carries no ids (expectClean).
  • A strip that can't be written doesn't fail the run.

Web

  • run-state applies tasks.updated.
  • On reload, thread.ts rebuilds the strip from chat_task_state through the person's session. If it can't be read, the chat opens without it.
  • components/chat/run/task-strip.tsx:
    • the header "Action Center tasks · N due", a progress bar and "X of N ready";
    • up to 4 rows (TaskStripRows): the task's title, "Priority 86 · Fix" and its status pill (Queued / Writing / Ready for review / Done) in both themes. A task with no title of its own shows its Action Center name from en.json, never a raw key;
    • when the run ends: "You close tasks in Action Center. I never mark them done." and Close tasks in Action Center.
  • Complete with Chat on Chat Home now sends /tasks Complete this week's Action Center tasks., so the skill loads.
  • skills/tasks/SKILL.md:
    • mark the work Ready for review when it's done;
    • then help with open Getting started steps, by stage. Chat never marks a step done or skips one.
  • Help: help/chat/chat.md gets "Work through your Action Center tasks" (approved: false).

Decisions: the user approved the screens and chose the header from the mockup plus the spec's rows. The queue cap is 4, as in the skill and the mockup.

Related issue

None. Chat Wave 2 (W2-11).

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Set CHAT_AGENTIC=true. Have a brand with open Action Center tasks, some due this week.
  2. On Chat Home, click Complete with Chat, or type /tasks.
    • The strip appears under the answer.
    • Rows move from Queued to Writing as Chat reads each action.
    • A drafted task shows Ready for review.
  3. Complete a task in Action Center and reload the chat: its row says Done, and "X of N ready" counts it.
  4. Reload during and after the run: the strip comes back as it was.
  5. Unit tests: task-strip, the engine hooks (engine.test), run-state, thread, the TaskStrip component, and the skills library.

Checked in the browser at 1024px, light and dark. The user approved the screens. Screenshots are available on request.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes (0 errors; 7 old warnings in files this PR doesn't touch)
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

On this branch (503ff17):

Next: W2-12 (attach a draft to its task and mark it done, on the person's click) builds on this strip's Done.

🤖 Generated with Claude Code

cihan-gyk and others added 16 commits October 31, 2026 03:42
…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]>
Resolves ansvisor#1897's and ansvisor#1900's chat files against main's W2-04..W2-25 work;
For you now's Complete tasks chip now types /tasks so the run keeps its
task strip, as the PR's Complete with Chat message did.
…e task strip (W2-11)

Undo of Ready for review puts back the Writing a /tasks run set, and the
run's own end has already settled its strip, so a reload showed Writing
under an answer that finished. A reload now reads an ended run's Writing
as Queued; a running run keeps it.
A /tasks run in a chat about one brand now takes no other brand's tasks
into its strip, as Ready for review already refuses them, so the strip
stays about the chat's brand for everyone who opens it.
gkhngyk
gkhngyk previously approved these changes Oct 31, 2026

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, with 2 fixes on top: this branch (043e07c, a fast-forward of 503ff17 with origin/main merged in). This review covers the two W2-11 commits only (c1bd974, 503ff17). #1897's part is reviewed separately.

Fixes

  • ac6961e: a reload could show Writing under an answer that had already finished. When Ready for review is undone, Undo puts back the status the task had before, and in a /tasks run that is Writing (get_action set it). The run's own end had already settled its strip, so the row stayed Writing for good. The same thing happens when a run never reaches its own end. On reload (thread.ts), an ended run's Writing now reads Queued, and a running run keeps Writing. The test fails without the fix.
  • 043e07c: a /tasks run in a chat about one brand could pull another brand's tasks into its strip, through list_action_center_tasks or get_action on a brand the person can also see. set_task_ready_for_review already refuses this. followTaskReads now skips a read whose brand isn't the chat's brand, so the strip only ever shows the chat's brand to whoever opens the chat. The test fails without the fix.

Merge with main

  • Main's Chat Home replaced Complete with Chat with the Complete tasks chip under For you now (#1889). That chip's message didn't start with /tasks, so the run never loaded the skill and had no strip. The merge adds /tasks to chatShell.home.forYou.tasksMessage, updates chat-home.test, and names the chip in the help page.
  • Conflicts against W2-04, W2-07, W2-19 and W2-25 were resolved keeping both sides. Main's readEarlierRuns keeps the PR's fromTaintedRun (the fromRunId taint), overBatchCard(tool, input, before) keeps alwaysCardWhen, cards carry both cardNotes and cardDetailsOf, ChatToolContext has both chat and pageSites, and finishStopped settles the strip using main's progress.

Checked, fine as is

  • Whose tasks: the brand comes from the precedence check (brand access included), and the service-role reads are scoped to that brand's open, non-deleted actions. The reload goes through the person's session, and the embed names one FK (action_tasks_action_id_fkey, checked on prod).
  • Week boundary: Monday to Sunday, in the run's time zone, matching Chat Home's endOfWeek. Overdue tasks count as due.
  • Statuses: Chat's own status only. action_tasks is never written, and Done is read from the task being completed in Action Center. The status change itself goes through #1897's set_task_ready_for_review, with its role and server checks.
  • Cost and limits: there are no new model calls or loops. The strip is bookkeeping on reads the run already makes (at most 4 rows, a few queries per update), and nothing polls. If a strip write fails, the strip update is lost but the run and its answer are not.
  • Untrusted text: task titles go to the browser only and are never put into a prompt. The model reads tasks through the existing tools and their taint rules.
  • Client bundle: task-strip.tsx imports only event types, and plan-row passes. en.json has every chatRun.tasks.* key, and the help section check passes.

Follow-ups (not blocking)

  • Chat Home's count includes on-hold actions (OPEN_ACTIONS in chat-home.ts), but the strip leaves them out. Home also counts actions while the strip header counts tasks, so "Complete tasks · 3 due" and "Action Center tasks · 4 due" can disagree.
  • pickTasks takes the top 50 open actions by priority before it filters for due dates. In a brand with more than 50, a low-priority action due this week can be missed.
  • The strip's status pills change without being announced (there's no live region), and the progress bar has no aria-valuetext ("1 of 3 ready").
  • When a later run takes a task, it becomes that run's row, so an earlier answer's strip loses the task on reload. This is documented in the code, but worth confirming that's what's wanted.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gkhngyk
gkhngyk merged commit 33a68c3 into ansvisor:main Oct 31, 2026
4 of 5 checks passed
gkhngyk added a commit to cihan-gyk/ansvisor that referenced this pull request Oct 31, 2026
Resolves help/chat/chat.md keywords, thread.ts imports and thread.test.ts against the squashed ansvisor#1897/ansvisor#1900 on main.
gkhngyk added a commit that referenced this pull request Nov 1, 2026
…e task strip's progress (#1942)

* feat(chat): ask once what Chat should focus on, starting from the person's work areas (W2-22)

CHAT-24 §3: the focus picker opens once on the first Chat Home (marked
shown as it opens) with the areas the person's work areas suggest, Home's
pill reopens it, and Settings › General › Your focus keeps changes at
once. Focus only changes suggestions; no migration (00400 focus, 00408
focus_prompted_at).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(chat): keep the focus actions open in read-only, as the person's own settings

saveChatFocus, skipChatFocus and markFocusPrompted write only the person's
own chat_user_prefs row and cost nothing, like saveChatGeneralSettings, so
they join the read-only coverage test's open list with their reasons.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(chat): leave a focus as it was when the picker opened from Home's pill is cancelled

From the pill the picker's way out still saved an empty focus, so changing
your mind wiped the focus you had. Opened from the pill it now reads
Cancel and only closes; Skip for now stays the first opening's answer.

* fix(chat): move focus into the focus picker and back, and announce the task strip's progress

Follow-ups from the #1914 and #1900 reviews, for keyboard and
screen-reader users.

Focus picker (stacked on #1914):
- Its question takes focus as it opens, from Home's pill or on the
  first Chat Home, instead of focus staying on body.
- Cancel or Continue from the pill hands focus back to the pill; Skip
  for now or Continue on the first opening lands on Home's composer
  (on the pill when the composer can't be typed in).

Task strip (/tasks, W2-11):
- A polite live region says what changed, once: the rows whose status
  moved ("Add FAQPage schema: Writing"), then "3 of 4 ready" when the
  count moved. A reload or the strip's first tasks say nothing.
- The progress bar has aria-valuetext ("2 of 4 ready").
- New text in en.json (chatRun.tasks.changed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Cihan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Gökhan Geyik <[email protected]>
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.

2 participants