Skip to content

feat(chat): show "For you now" on Chat Home, each job with its count (W2-05) - #1889

Merged
gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-05-for-you-now
Oct 31, 2026
Merged

gkhngyk merged 3 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-05-for-you-now

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat W2-05: "For you now" on Chat Home (v2 mockup #s-home .scut, CHAT-08 v2). Behind CHAT_AGENTIC. The owner approved the screen in a preview.

What it shows: Ask anything first, then each job that has something to do, with a count from the brand's data, then More ▾, which opens the composer's / menu. The jobs:

  • Complete tasks · N due: this week's Action Center tasks: new, in_progress or on_hold, due by Sunday in the person's time, overdue included. It replaces Home's old Action Center line.
  • Win back citations · N pages: the pages named by open lost_citations signals. They're keyed as the server keys them (pageKey: no query or hash, no www, no trailing slash), so a page counts once.
  • Ready to publish · N: drafts marked ready and not archived. This is the same count as the Library's Ready tab.

A chip starts a new chat with its words. The words follow W2-04's skills (#1885):

  • Complete tasks prepares the work; the person closes the tasks.
  • Ready to publish checks the drafts, fills their page fields and sends them to the CMS as drafts. Going live stays the person's click.

Who sees what

  • People who can't change things (Analyst, Agency partner) get only the jobs that read: Win back reads as "Show the N pages that lost citations and what AI cites instead". They get no More, since their composer has no / menu.
  • A job whose menu section an Admin hid (Menu access, 00374) isn't counted or shown: Win back → Citations, Ready to publish → Content. Action Center can't be hidden.
  • A read that fails hides the jobs; Ask anything stays. A brand switch reads again and never shows the previous brand's counts.

Reads: one server action (readHomeShortcuts) reads the person once and the three counts in parallel (count: 'exact', head: true where it can). The lost-citation pages are read 1,000 signals a page, with only payload->lostUrls selected.

Accessibility:

  • the chips have the repo's focus ring;
  • the row is a named group;
  • the count is spoken ("Complete tasks 4 due");
  • the arrow is hidden from screen readers;
  • numbers use {count, number}.

Help: the Chat Home paragraph in help/chat/chat.md is updated.

Related issue

None. Chat Wave 2 (W2-05).

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, give the brand a task due this week, an open lost-citation signal and a ready draft. Open Chat Home.
    • For you now shows Ask anything, Complete tasks · 1 due, Win back citations · N pages, Ready to publish · 1 and More ▾.
    • Click a job: a new chat starts with its words. Click More: the / menu opens.
  2. Sign in as an Analyst. Only Win back (read form) shows, and More doesn't.
  3. Hide Citations for the role in Settings › Menu access. Win back disappears.
  4. Run yarn vitest run src/components/chat/chat-home.test.tsx src/lib/actions/chat-home.test.ts.

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 dac323a: 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,030 of 3,031. The one failure is chat-menu.test.tsx's clock case, fixed in #1876.

Follow-ups, not in this PR

  • Quality pass and Weekly report join the jobs once their data exists: drafts' quality scores aren't stored yet, and schedules come in Wave 3.
  • W2-19 (Since you left) also changes Chat Home. Whichever merges second takes the other's chat-home.tsx.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 31, 2026 04:14
…(W2-05)

Chat Home's "For you now" (mockup #s-home .scut, CHAT-08 v2): Ask anything
first, then the jobs with something to do, each with its count from the
brand's data, then More, the composer's / menu. Complete tasks counts this
week's Action Center tasks (it replaces the Action Center line), Win back
citations the pages the open lost-citation signals name, Ready to publish
the drafts marked ready. A chip starts a new chat with its words. Quality
pass and Weekly report wait for their data (drafts' quality scores aren't
kept; schedules come in Wave 3).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s' words (W2-05 review)

The jobs ask in W2-04's skills' words: Complete tasks prepares the work and
the person closes the tasks; Ready to publish checks the drafts, fills their
page fields and sends them to the CMS as drafts, going live staying the
person's click. Someone who can't change things (Analyst, Agency partner)
gets the jobs that only read and no More, which their composer has no menu
for; a job whose menu section an Admin hid isn't counted. One action reads
the person once and the three counts together; the lost-citation pages are
read a page of signals at a time, keyed as the server keys them. The chips
get the focus ring, a named group, a spoken count and a hidden arrow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Looks good as is, no fix needed.

What we checked

  • Chat off. The page answers notFound() without CHAT_AGENTIC or outside CHAT_AGENTIC_ORGS. readHomeShortcuts reads the person's profile, then returns { ok: false } before it reads the role menu or any count. A test covers signed out, Chat off, a bad brand id and a bad date.

  • Whose counts. All four reads use the person's own session client, so RLS decides. The actions, signals and content_drafts select policies all reach the brand through brands joined to the caller's profile. A brand of another organization counts 0. The brand-access work (00389 narrows brands itself) carries over to these three policies without any change here. Someone with Selected brands will only get counts for their own brands.

  • Counts match the pages they stand for.

    • Complete tasks: the same query as the old Action Center line (new/in_progress/on_hold, due by the end of the person's week). The actions policy already leaves deleted ones out.
    • Ready to publish: status = 'ready' and not archived. That's the same filter as the Library's Ready tab (libraryTabCounts / countLibraryTabs).
    • Win back: the distinct pages named in the open (new, acknowledged) lost-citation signals' evidence. Those are the pages the signals' detail panels list. The key follows the server's pageKey (no scheme, www, query, hash or trailing slash).
  • Role. canChange is useUserRole().canManage (Admin, Manager), the same rule the composer uses for its read-only mode. Analysts and Agency partners get only Win back in its read form, and no More, which matches their composer having no / button.

  • Menu access. Win back follows citations and Ready to publish follows content, using hiddenByAdmin (the Admin's role and person settings, not the person's own work areas). A hidden section isn't counted at all. Action Center is always on, so Complete tasks can't be hidden.

  • Query cost. One profile read and the role-menu row, then the three counts in parallel. Two are head: true counts. The signals read selects only payload->lostUrls, a page of 1,000 at a time, with a 20-page stop. On the largest brand in production the plans are:

    • signals: signals_brand_status_idx, about 1.6 ms;
    • actions: the brand index, about 1 ms;
    • drafts: about 0.2 ms.

    There's no N+1. It runs once per brand and week, with no polling.

  • Stale answers. A brand switch drops the older answer (the current flag), and the counts are keyed by brand, so the previous brand's counts never show. A rejected action hides the jobs and keeps Ask anything.

  • Read-only and demo. The action only reads. A chip starts a chat through the existing /api/chat/runs path. That path keeps its 402 → upgrade dialog and the demo guard. The guid() check accepts the demo brand's id, and a test covers it.

  • Targets. Ask anything and More find composer.input and composer.openSlash, which the composer renders (More only when the composer isn't read-only, which is the same rule). Nothing links to a route.

  • A11y. The row is a role="group" named by its title. The chips are real buttons with the focus ring, and they're disabled while a chat starts. The count is part of the button's name. The arrow is aria-hidden. Numbers use ICU number/plural.

  • Removed strings. countDueActions, completeWithChat, completeTasksMessage and home.completeTasks have no callers left.

  • Embeds: none.

Follow-ups (not blocking)

  1. A lost-citation signal raised before its evidence was stored names no page, so its brand gets no Win back chip. Production has one brand like that (3 open signals, no evidence). Falling back to the signal count, or re-recording the evidence, would cover it.
  2. Each signal stores at most 3 lost pages (MAX_LISTED), so the count is the pages the signals name, not every page that lost citations. The help text's "pages that lost citations" reads fine as it is.
  3. Nit: More could carry aria-haspopup like the composer's / button.

Tests

Run on the PR head (dac323a21):

  • chat-home.test.tsx (14), chat-home.test.ts (6) and plan-row.test.ts (2): passing.
  • components/chat, lib/chat, the Chat pages, lib/guards, lib/demo, subscription-guard-coverage and demo-gate-routes: 1,241 of 1,242 pass. The one failure is chat-menu.test.tsx's clock case, in a file this PR doesn't touch, which #1876 fixes.
  • tsc --noEmit: clean. eslint and prettier on the changed web files: clean.
  • Merging on current main: the PR is already on main's tip, so it's clean.
  • Conflicts with other open PRs:
    • #1890 (W2-19) conflicts in chat-home.tsx, its tests, chat-home.ts, en.json and help/chat/chat.md, as the PR expects.
    • #1885 and #1876 conflict only in help/chat/chat.md.

@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 4d6fc42 into ansvisor:main Oct 31, 2026
4 of 5 checks passed
gkhngyk added a commit that referenced this pull request Nov 7, 2026
…uns next (#2213)

#1889 (W2-05) left Quality pass and Weekly report out of Chat Home's
For you now until their data existed. Scheduled jobs have merged
(W3-01 to W3-04b), so Weekly report joins the jobs, as CHAT-08 v2's
mockup has it: "Weekly report · Mon".

- readHomeShortcuts also reads, as the person, when their own Weekly
  report job for the brand runs next: a recurring /report job that is
  on, within the next 7 days. Reports taken off their menu hides it,
  as for the other jobs; a failed read hides the jobs.
- The chip carries that run's weekday in the person's time and asks
  "/report Write this week's report on our AI visibility." in a new
  chat. It only reads, so read-only roles get it too. With a focus
  picked, the seo area's Weekly report shortcut carries the same day.

Quality pass still waits: drafts' Quality scores are worked out in the
editor and never kept, so nothing can count drafts under 60.

Help: help/chat/chat.md's For you now paragraph; Since you left gets
its own section so Chat Home stays within 150 words.


Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9

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