Skip to content

feat(chat): add the Inbox's tabs and the daily suggestion rows (W2-25) - #1892

Merged
gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-25-inbox-suggestions
Oct 31, 2026
Merged

gkhngyk merged 6 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-25-inbox-suggestions

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat W2-25: the Inbox's tabs and the daily suggestion rows (CHAT-26, mockups #d-inbox and #d-paused). Behind CHAT_AGENTIC. W2-24 (#1872) picks one suggestion per person and brand each morning; this shows them. The owner approved the screen in a preview, and the review fixes were checked again in the browser (1024px, light and dark).

The Inbox (/dashboard/chat/inbox)

  • Tabs: All · Daily suggestions · Needs you · Runs, each with its count.
    • One tab stop; the arrow keys, Home and End move between tabs.
    • aria-controls with a tabpanel.
    • The open tab stays in the address (?tab=), so coming back from a row opens the same one.
  • A suggestion row:
    • its title, then the brand (when the person has more than one), AC-n, priority, where it can be done and how long it takes;
    • the day it was sent: "Today" uses the zone the nightly job dates sent_on in;
    • Open, filled while unread.
  • Rows that changed:
    • An action done or dismissed since keeps its row, faded, marked Done or Dismissed, without a filled Open.
    • A deleted action's row leaves the list: the read joins the action through the session, whose policy hides deleted actions, and opening one writes nothing.
    • A suggestion put off (snoozed_until) stays out until its day.
  • Daily suggestions tab:
    • While on: a line with Pause daily suggestions.
    • While any brand's feed is paused (by the job after 30 unused days) or off: the paused banner with Turn back on, which turns every brand's on.
  • Counts: the tab, the subtitle and All count every suggestion. "Showing the newest 100 of N." appears if the list stops at 100.
  • Open: goes to the action in the Action Center until W2-26's detail page. Marking it opened never blocks that, and a double click runs once.

Server actions (web/src/lib/actions/chat-suggestions.ts)

  • Every action reads the person's own suggestions (user_id + organization) and checks the plan first (assertWritable), returning { ok, failure }.
  • The first Inbox visit starts the feeds for the person's brands. An Agency partner's feeds turn on here (W2-24 / DECISIONS V).
  • Analysts get none.
  • Action Center is on every menu (00374, ALWAYS_ON_SECTION), so menu access doesn't turn suggestions off. A test fails once that changes: the Inbox must then respect Action Center access (CHAT-26 §6).

Help:

  • New help/chat/daily-suggestions.md (approved: false): who gets them, the rows, closed and deleted actions, brand names, pause and resume.
  • help/chat/chat.md says the Inbox count in the menu leaves suggestions out; their tab has its own.

Related issue

None. Chat Wave 2 (W2-25, CHAT-26).

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. With Chat on and W2-24 (feat(chat): pick one daily suggestion per person and brand each morning (W2-24) #1872) running, or rows put in chat_suggestions, open Chat › Inbox:
    • All and Daily suggestions list the rows; an unread row has a dot and a filled Open.
    • Open goes to the action.
  2. Mark an action completed: its row fades and says Done. Delete one: its row goes.
  3. Pause a brand's feed (chat_suggestion_feeds.status = 'paused'): the banner shows on Daily suggestions; Turn back on clears it.
  4. Run yarn vitest run src/lib/chat/daily-suggestions.test.ts src/lib/actions/chat-suggestions.test.ts src/components/chat/chat-inbox.test.tsx.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

On c5915af: format:check and typecheck pass, lint has 0 errors (7 old warnings), yarn build passes, and the chat, lib/chat and app suites pass 3,068 of 3,069. The one failure is chat-menu.test.tsx's clock case, fixed in #1876.

Review: the pre-push review found no blocker. Its shoulds are fixed in 2cd1000 and c5915af:

  • deleted actions' rows;
  • a paused brand without the banner;
  • the menu rule;

Its smaller items are in too:

  • the org filter on the first read;
  • snooze;
  • brand names;
  • a row whose brand isn't in the list;
  • double click;
  • the "Today" zone;
  • the full count;
  • the tabs' keyboard.

Follow-ups, not in this PR

  • W2-26: the suggestion's detail page (#d-detail); Open will go there.
  • The "Today" zone rule copies W2-24's resolveZones, ZONE_DAYS and ZONE_ANSWERS (server/src/lib/chat-suggestions). The two must stay in step; a comment says so.
  • Brand-level access: when W2-24 is on main, its job builds feeds only for brands a person can see (brand access PR 8 follow-up).

🤖 Generated with Claude Code

cihan-gyk and others added 5 commits October 31, 2026 01:17
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.

@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 1 fix on top: commit 9782b0a ( a fast-forward of c5915af with origin/main merged in).

Fix

  • 9782b0a: starting or turning on daily suggestions read the workspace's brands with the service role, so feeds were made for every active brand. That read now goes through the person's session (brands: member select), and so does the read before opening a suggestion. Both now follow the brands the person can see as brand access narrows them (00389, 00424). The writes stay the server's, on the person's own rows. Two tests cover this, and both fail without the fix. The help page now says Admins and Managers get suggestions "for every brand they can see".

Checked, fine as is

  • Counts: All = chats + every suggestion, Daily suggestions = the full count, and Needs you + Runs split the chats. "Showing the newest 100 of N" appears when the list stops at 100. The count respects the inner join, so a deleted action's suggestion isn't counted.
  • Reads: the list and the feeds go through the session (00422's own-row policies, and 00424 adds brand access later). The time-zone read uses the service role, scoped to the workspace, and only the day leaves the server. It matches W2-24's resolveZones, ZONE_DAYS and ZONE_ANSWERS.
  • Embeds: both hints name an existing single FK (chat_suggestions_action_id_fkey, chat_messages_conversation_id_fkey).
  • Query cost: one read per Inbox load. Nothing polls, and seen ids are de-duplicated. The time-zone query uses the conversation-org and message-created indexes (EXPLAIN on prod).
  • Flag off: the page 404s, and every action answers chat_off and touches nothing.
  • Read-only workspace: every write calls assertWritable first and answers read_only. The UI then opens the plan dialog. subscription-guard-coverage passes.
  • Demo brand: no feeds for it.
  • Write actions: they are idempotent (seen_at/opened_at are only set while null, and the upserts use ignoreDuplicates), and a double click runs Open once.
  • ?tab= falls back to All for an unknown tab.
  • Tabs: one tab stop, arrow keys plus Home/End, and aria-selected, aria-controls and a labelled tabpanel.
  • en.json: every key the new components use is there.
  • plan-row passes, so the client components don't import the server's Supabase client.
  • Help: the 150-word section check passes.
  • Open PRs: merges cleanly with #1876, #1885, #1889 and #1890.

Follow-ups (not blocking)

  • startDailySuggestions checks whether the person already has feeds with the service role, across all brands. Once brand access is on, someone whose only feeds are for brands they can no longer see would get none made for their visible ones. Reading that check through the session would close this.
  • Turning suggestions back on also turns on feeds for brands the person no longer sees. The nightly job should skip those (the brand access PR 8 follow-up already listed).

Tests run (on that commit)

  • vitest: src/components/chat, src/lib/chat, the chat-suggestions actions, the chat pages, src/lib/guards, src/lib/help, src/lib/demo and subscription-guard-coverage. 1,313 of 1,314 pass. The one failure is the known chat-menu.test.tsx clock case, fixed in #1876.
  • tsc --noEmit is clean. eslint and prettier pass on the touched TS files.

@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 0ad82c0 into ansvisor:main Oct 31, 2026
4 of 5 checks passed
gkhngyk added a commit that referenced this pull request Oct 31, 2026
…tor, Do it with Chat, Not now and Remove (W2-26) (#1898)

* feat(chat): add the Inbox's topic tabs and daily suggestion rows (W2-25)

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 (#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]>

* fix(chat): hide deleted actions' suggestions, show a paused brand, and 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]>

* refactor(chat): drop the Inbox's Action Center menu check, which can'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]>

* fix(chat): read the brands and the suggestion to open through the person'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.

* feat(chat): open a daily suggestion on its own page, with Content Editor, 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]>

* fix(chat): end the suggestion page's "Why now" with one full stop (W2-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]>

* test(chat): read the suggestion page's rows through the person's session, after #1892's fix (W2-26)

#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]>

* fix(chat): make one move of a double click on a suggestion's page, and 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.

* test(chat): give the suggestion page's composer setup its skills, as 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.

---------

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