Skip to content

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

Merged
gkhngyk merged 5 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-22-focus-picker
Nov 1, 2026
Merged

gkhngyk merged 5 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-w2-22-focus-picker

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat W2-22: a focus picker asks what the person works on, so Chat can fit its Home, starter questions and skills to them (CHAT-24, mockup CHAT-mockup-v2.html#s-dept). Built on main. No migration: chat_user_prefs.focus (00400) and focus_prompted_at (00408) already exist. Behind CHAT_AGENTIC.

Focus and work areas are separate. Work areas (00374) only hide sections of the left menu. Focus only shapes Chat's suggestions. Neither changes access, and the picker says so. The picker is prefilled from the person's work areas but doesn't save them. After that the two stay independent:

Work area Focus
leaders lead
aeo seo
content content
brand brand
growth growth
product pd
bizdev bd
analytics growth
developers seo

comp has no work area.

What it does

  • lib/chat/focus.ts:
    • the 8 areas;
    • the work-area mapping (focusFromWorkAreas), focusOf, focusLabel;
    • the Zod schema (known keys, no repeats, at most 8).
  • chat-prefs.ts: saveChatFocus, skipChatFocus (sets {}) and markFocusPrompted. They never throw, and each writes only the person's own row.
  • Who is asked: _chat-page-access.ts → chatFocusState() returns { focus, ask, prefill }. ask means focus is null and the person was never prompted. If the read fails, Home opens without the picker.
  • The picker (focus-picker.tsx) opens once, on Chat's first open:
    • eight toggle cards, in two columns (four on wide screens);
    • Continue needs at least one pick, and Skip for now is never asked again;
    • focus_prompted_at is written when it shows;
    • Home stays mounted underneath (invisible h-0 overflow-hidden), so a draft isn't lost and the composer measures its full height.
  • Home: a pill under the greeting: "Focused on … · Edit", or "Get suggestions for what you work on · Choose focus".
  • Settings › General › Your focus: eight checkboxes, saved on change. Reader roles see it too. Main is merged in (0cdf02f): the rows fix(chat): hide the three Chat settings that don't do anything yet #1903 hid stay hidden.
  • PostHog: chat_focus_picker_shown, saved, skipped.
  • en.json chatShell.focus.* and settings.focus.*.
  • Help:
    • new help/chat/focus.md (approved: false);
    • "Your focus" section in chat-settings.md.

Left out on purpose

  • An Admin suggesting a focus while inviting someone: work areas already do this.
  • Focus in a personal-data export: the app has no such export. The row is removed with the user (on delete cascade).

Next: W2-23a fits Home to the focus (stacked on this). W2-23b adds the focus-tagged skills.

Related issue

None. Chat Wave 2 (W2-22).

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. Use a person with work areas Product Development and Business Development, who has never been asked.
  2. Open Chat. The picker opens once, with Product and Markets picked. Continue saves the picks, and Home shows "Focused on Product and Markets · Edit". Its composer has its full height.
  3. Reload: no picker. Skip for now, on another person, also never asks again.
  4. In Settings › General › Your focus, change the boxes. Home's pill follows without a reload.
  5. Unit tests: focus, chat-prefs, _chat-page-access, focus-picker, chat-home and chat-settings.

Checked in the browser at 1024px, light and dark: the first open, Home's pill, Settings › Your focus, and the composer after Continue. 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)

Full checks on 0cdf02f (this branch with main merged in): web 800 of 801 files / 8,353 tests passed, and yarn build passes. Server format:check and lint are clean, and 351 files / 4,987 tests pass (3 skipped). The one failing file was subscription-guard-coverage.test.ts, because the three focus actions weren't on its list. 9f3e727 adds them to the open list: like saveChatGeneralSettings, they write only the person's own row and cost nothing. That file now passes (6/6).

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 31, 2026 23:20
…son'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]>
Main hid Answer language, notifications and "Thought for N s" in Chat
Settings (ansvisor#1903). Keep them hidden and keep the new Your focus row, in
the component, the page comment and the help article.

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

@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 1793813 (on top of this branch merged with current main).

Fix: cancelling the picker from Home's pill wiped the focus. When the picker opened from the pill (Edit / Choose focus), its "Skip for now" still called skipChatFocus(), which saved focus: []. Someone who opened Edit and changed their mind lost their focus. Now, when the picker opens from the pill, the button reads Cancel and only closes it: nothing is saved, no chat_focus_skipped event fires, and the next Edit opens with the same picks. The first-open picker still shows Skip for now and saves no focus, as before. The change adds a chatShell.focus.cancel key and one line about it in help/chat/focus.md. focus-picker.test.tsx gets a test for it, which fails without the fix.

Checked and fine:

  • The three new actions write only the person's own chat_user_prefs row. They go through chatPerson(), so the CHAT_AGENTIC flag applies, and on prod the row's select/insert/update policies are all user_id = auth.uid(). Keeping them open to read-only roles in the subscription-guard coverage list is right: focus only shapes suggestions.
  • focusPicks validates each pick against the eight areas and rejects duplicates. focusOf drops unknown values on read.
  • focus and focus_prompted_at exist on prod. The picker marks itself prompted as it opens, so it really shows only once.
  • Picker a11y: the cards are aria-pressed toggle buttons inside a labelled group. Home underneath is visibility: hidden, so it is out of the tab order and the accessibility tree.
  • help/chat/focus.md: every section is under 150 words. It is still approved: false, so the approved-articles snapshot doesn't change.

Follow-up (not blocking): focus isn't moved into the picker when it opens from the pill, or back to the pill when it closes. Keyboard and screen-reader users land on body.

Tests: vitest on src/components/chat, src/lib/chat, the chat pages, src/lib/actions, src/lib/guards (plan-row included), src/lib/help, subscription-guard-coverage and demo-gate(-routes): 228 files and 2578 tests pass. tsc --noEmit is clean, and eslint and prettier are clean on the touched files.

@gkhngyk
gkhngyk merged commit 87cdb8c into ansvisor:main Nov 1, 2026
5 checks passed
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