Repository navigation
feat(chat): open a daily suggestion on its own page, with Content Editor, Do it with Chat, Not now and Remove (W2-26) - #1898
Conversation
Behind CHAT_AGENTIC (and CHAT_AGENTIC_ORGS): with it off the Inbox page
answers as it does today, and a read that says chat_off keeps the Inbox as
it was, with no tabs.
- Topic tabs (CHAT-26 §2.1, mockup #d-inbox) with their counts: All, Daily
suggestions, Needs you and Runs. Reports and Alerts stay hidden until
they have a source (CHAT-12, CHAT-22). The subtitle keeps its counts and
adds "N suggestions this week". An Analyst, who gets none, has no Daily
suggestions tab.
- Daily suggestion rows (§2.2): the last 7 days (sent_at > now − 7 days,
not removed), newest first. The title comes from actionTexts and the
priority from the Action Center's own levels, read from the summary W2-24
keeps (version 1). The row also shows AC-number, how it is done
("Content Editor or Chat · about 20 min", "started in Content Editor
Oct 27") and the day it was sent ("Today · Oct 29"). Its dot is new
(blue), seen or started (green), with dark-mode colors.
- Rows on screen (All or Daily suggestions) are marked seen, which isn't a
use. Opening one marks it opened and its feed's last_used_at, then opens
the action in the Action Center on its brand (until W2-26's page).
- The line above the rows with Pause daily suggestions (every feed of the
person off), and the paused banner (§2.4, #d-paused) with Turn back on
(status on, paused_at null). The job's next-morning rule still reads
updated_at.
- An Agency partner's first Inbox makes their feeds, on, for the
workspace's active non-demo brands, with a line saying so (DECISIONS V).
Admins' and Managers' feeds stay the job's to make; Analysts get none.
- Writes go through server actions in lib/actions/chat-suggestions.ts.
Each checks the plan first (assertWritable), writes with the service role
on the person's own rows only, and answers { ok, failure } without
throwing (ansvisor#1777). Reads go through the person's session (00422 RLS). In
a read-only workspace the list shows, nothing is written, and Pause or
Turn back on opens the plan dialog.
- The page's live part (chat-inbox-page.tsx) is kept apart from
chat-inbox.tsx, so the Chat shell, Home and All chats don't import the
server actions.
- Help: a Daily suggestions article (approved: false) and the Inbox's tabs
in the Chat article.
No Settings › Notifications switch: the mockup has none, so only the
Inbox's link turns them off.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…d respect Action Center access in the Inbox (W2-25) Review fixes for the Inbox's daily suggestions (CHAT-26), on top of 2bbd08c. - A suggestion whose action was deleted leaves the list: the read joins its action through the person's session (actions!chat_suggestions_action_id_fkey!inner), whose policy hides deleted actions. Opening one checks the same (actions.deleted_at null) and writes nothing. An action done or dismissed since keeps its row, faded, with Done or Dismissed in place of how it can be done, and no filled Open. - The paused banner shows while any brand's feed is paused (§2.4, §5); Turn back on already turns every brand's on. - No Daily suggestions tab or rows for someone without Action Center on their menu (§6, 00374), and Pause, Turn back on and the first Inbox make or turn on no feed for them. Action Center is on every menu today (ALWAYS_ON_SECTION); the check follows the menu's own rule. - A suggestion put off (snoozed_until) stays out until its day. The first Inbox's feed read is the workspace's only. - "Today" is dated in the zone the nightly job dates sent_on in (its resolveZones: the person's latest Chat answer's zone, else the workspace's most read one, else UTC), not the browser's clock. - The read counts every suggestion it would list (count: exact): the tab, the subtitle and All count them all, and a line says "Showing the newest 100 of N." when the list stops at 100. - A row names its brand when the person has more than one; a row whose brand isn't in their brand list doesn't open (it would open on the brand on screen). An action with no kind still has a title. Open runs once on a double click, and still navigates when marking it fails. Open goes to the Action Center until W2-26's page (a comment says so). - Tabs: one tab stop, the arrow keys, Home and End, aria-controls and a tabpanel. The open tab is kept in the address (?tab=), so coming back from a row opens the same one. - Help: who gets them (Action Center in the menu), closed and deleted actions, brand names, pause per brand; the Inbox count in the Chat article leaves suggestions out (their tab has its own count). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t trigger (W2-25) Follow-up to 2cd1000. Action Center is on every menu (menu access, 00374: ALWAYS_ON_SECTION, which hiddenMenuSections never hides), so the suggestions' menu check was dead code that cost a read of the role's menu on every Inbox. It goes, and a test keeps the assumption: it fails, saying "W2-25 daily suggestions must then respect Action Center access (CHAT-26 §6)", once Action Center can leave a menu. - Help: daily suggestions come from the Action Center, which is in everyone's menu, so menu settings don't turn them off. - The "Today" zone rule says it copies W2-24's resolveZones, ZONE_DAYS and ZONE_ANSWERS (server/src/lib/chat-suggestions), to keep in step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…son's session (W2-25) Starting or turning on daily suggestions made feeds for every active brand of the workspace, read with the service role; opening one read the row the same way. Both now read through the person's session, so they follow the brands they can see (brands: member select, and chat_suggestions' own policy) as brand access narrows them. The writes stay the server's, on the person's own rows. The help page says Admins and Managers get them for every brand they can see.
…tor, Do it with Chat, Not now and Remove (W2-26) CHAT-26 §2.3, mockup #d-detail, built as "Why did it move?" (#f-why): - /dashboard/chat/inbox/[id]: the action's title as the question, "Picked for you today · no AI cost", what was read (the action, the ranking, its pages' last Site Audit), why this / why now / what it takes from the action's own texts, and the "From your Action Center" card. - Content Editor (only with writing to do) opens the action's draft on its first page; Do it with Chat starts a chat scoped to the action (page, brand and action chips) in the workspace's mode; the composer under the page does the same. Both mark the suggestion started (chat | editor). - Not now (7 days) and Remove go back to the Inbox; the action stays. - readDailySuggestion, snooze/remove/started actions sharing one use path with openDailySuggestion; each checks the plan first. - The Inbox's Open goes to the page, which marks it opened; the breadcrumb reads Chat › Inbox › Daily suggestion · Oct 29. - No data row line until P-1 writes play.dataRow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-26)
The priority reason is already a sentence (priority.reason.sentence.end),
so "Why now: {reason}" adds no stop of its own; seen in the preview.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-w2-26-suggestion-page # Conflicts: # web/src/lib/actions/chat-suggestions.ts
…ion, after ansvisor#1892's fix (W2-26) ansvisor#1892 (9782b0a) reads a suggestion to open, and the brands, through the person's session, and its test client answers a maybeSingle() read from a '….select.single' default. The page's read and its uses now follow it: - readDailySuggestion's tests drop that default, so the page reads its whole row as before; - the uses (Not now, Remove, started) set their read on the session's single answer, and a new test checks the read goes through the session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # help/chat/daily-suggestions.md # web/messages/en.json # web/src/components/chat/chat-inbox-page.tsx # web/src/components/chat/chat-inbox.test.tsx # web/src/components/chat/chat-shell.tsx # web/src/lib/actions/chat-suggestions.test.ts # web/src/lib/actions/chat-suggestions.ts # web/src/lib/chat/daily-suggestions.test.ts # web/src/lib/chat/daily-suggestions.ts
…d keep it busy while its page opens (W2-26) Not now, Remove, Do it with Chat and Content Editor set busy through state, so a second click in the same frame started the move again, and a move that succeeded freed the buttons while its page was still opening (a Remove after a Not now). A ref now holds the move from the first click; one that fails frees the buttons, one that succeeds stays busy.
…main's type now asks (W2-26) main added skills to ChatComposerSetup (W2-04's / menu), so the test's setup no longer type-checked after the merge.
gkhngyk
left a comment
There was a problem hiding this comment.
Approving, with 1 fix on top: commit 96762d2 (plus 8909d87, a test type fix from the merge). Branch this branch is this PR's head with main merged in, then the two commits, so it fast-forwards the PR.
The merge. Main squashed #1892, so the PR's copy of #1892 came back as add/add conflicts in 9 files. Seven of them are the same as main's #1892 except for this PR's own changes, so I kept the PR's side. That includes #1892's read of the suggestion and its brands through the person's session, which is unchanged in chat-suggestions.ts. chat-shell.tsx and en.json were merged by hand: main's AGENT_PATH (New agent and Edit) now sits next to this PR's SUGGESTION_PATH and DETAIL_PARENTS.
Fixes
- 96762d2: a double click on the page's moves. Not now, Remove, Do it with Chat and Content Editor only became disabled after React re-rendered with
busy. Two clicks in the same frame started a move twice. Also, a move that worked setbusyback to false infinally, so the buttons came back on while the Inbox or editor was still loading. That allowed a Remove right after a Not now, or a second draft start. A ref now holds each move from the first click. A failed move frees the buttons, and a successful one stays busy while its page opens. The started-once flag moved into a small hook, the same way, to keepreact-hooks/refsquiet. New test: "makes one move of a double click", which fails without the fix. Two existing tests now remount between moves, because a move that works keeps the page busy. - 8909d87.
ChatComposerSetupgotskillson main (W2-04), so the test's setup failedtscafter the merge.
Checked and fine
- The page. A bad id or the flag off gives 404. Someone else's, removed or deleted suggestion shows "isn't available", with no difference between the cases.
- Reads. All reads go through the person's session, and RLS checks the user, the org and brand access. Actions RLS hides deleted ones.
personTodayis still the only service-role read, scoped to the org, with only the day sent back. - Writes. Opened, snoozed, removed and started go through
recordUse. It first reads the row through the session, then writes with the service role, filtered byid+user_id. The opened and started stamps are first-write-only. - Plan check.
assertWritableis the first await of every exported action. The page doesn't record the open while the workspace is read-only, and each move opens the plan dialog. - Content Editor. It hands off to the existing
startDraftFromAction, on the suggestion's own brand, which the RLS read already let through. That function checks that the task belongs to the action and the page belongs to the action's pages, and it reuses a draft that already exists. - Do it with Chat. It posts to
/api/chat/runsthe same way Chat Home does, with thesubscription_inactiveplan dialog. Its chips fit the run's schema (label up to 200). - Untrusted text. The action's title, its story and the page paths are rendered as text.
- Embeds and query cost. The embeds name
chat_suggestions_action_id_fkey. The added queries use indexed or small lookups (action_tasks_action_idx,site_auditsby brand). - Client bundle. Client imports are type-only or come from
'use server'modules. - en.json and help. All the keys are there. The new help section is 145 words.
Follow-ups (not blocking)
- A message sent from the composer while Do it with Chat is still starting can open a second chat. The two paths don't share the busy state.
recordUsedoesn't skip a removed row. A stale tab's Not now or Remove still "works" and stamps the feed as used. It's harmless, but.is('removed_at', null)on the read would make it exact.site_audits.urlis matched exactly against the action's pages. If the URL forms differ (a trailing slash, http vs https), "Checked the pages" won't show.
Tests: vitest on src/components/chat, src/lib/chat, src/lib/actions, src/lib/guards (with plan-row), src/lib/content, src/lib/help, subscription-guard-coverage, mcp/demo-gate-routes and the chat pages all pass. The one exception is engine.test.ts "keeps the setup rows…", which times out at 5s; it does the same on main's files, so the cause isn't this PR. tsc --noEmit is clean. eslint and prettier pass 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-26 gives each daily suggestion its own page,
/dashboard/chat/inbox/[id](CHAT-26, mockup#f-whydaily suggestion). Opening a suggestion from the Inbox now goes to this page, and the page records that it was opened. Stacked on #1892 (W2-25); review only the commits after its head. Everything stays behindCHAT_AGENTIC/CHAT_AGENTIC_ORGS. No migration.The page, top to bottom
ChatThreadViewdock) with page, brand and action chips. Sending a message starts a chat on the suggestion. Do it with Chat posts to/api/chat/runsthe same way.startDraftFromActionuses the action's first open writing task (create first, then optimize; optimize opens the first page), then goes to the editor.Server
readDailySuggestionreads with the person's session:ACTION_COLUMNS/actionItemFromRow), with assignees, entity counts and tasks;An Analyst gets
not_found.snooze(+7 days),remove,started(chat|editor)andopenDailySuggestionshare onerecordUse. Each writes the feed'slast_used_at, so they count for the 30-day rule.The plan check is the first await of every exported action (the coverage test asks for it).
TASK_DONEis exported fromaction-drafts.tsand reused.Inbox
?tab=suggestions.Help:
help/chat/daily-suggestions.mdgets "The suggestion's page" and adds start, snooze and remove to the 30-day rule (approved: false).Related issue
None. Chat Wave 2 (W2-26).
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. Have a daily suggestion for your user and brand (W2-24's picker, or a row inchat_suggestions).daily-suggestionsserver actions, the Inbox tests, and the read-only coverage test.Checked in the browser at 1024px, light and dark: a full page, a closed action (Done) and a Chat-only suggestion. 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 (with #1892's head 9782b0a merged in; its brand-access reads kept in the page's uses):
format:checkandtypecheckpass, and lint has 0 errors. 760 files / 7,718 tests. The full run caught 6chat-suggestions.test.tscases still using the old test client after the merge. The last commit moves them to the session's single answer, and the file now passes 37/37. The only other failure ischat-menu.test.tsx"Done · 08:02", a date-dependent case that fix(chat): give a chat row the menu's clock, so a run's time matches its day #1876 fixes.yarn buildpasses.format:checkand lint are clean. In the full run, two timing tests (page-content,content-people) failed on a loaded machine; they pass alone (64/64).🤖 Generated with Claude Code