Repository navigation
feat(chat): fit Chat Home to the person's focus: shortcuts, starter questions and a competitor's rise (W2-23a) - #1915
Conversation
…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]>
…uestions and a competitor's rise (W2-23a) CHAT-24 §4: For you now takes the picked areas' shortcuts in turn (five beside Ask anything, CHAT-08 v2's six chips; the three jobs keep their counts and rules), Start with a question offers four in the workspace's own competitor, topic and market or their general wording, the line under the greeting says a competitor's mention rate rose 3+ points this week when nothing needs the person, and the / menu lists the focus's skills first. No migration. 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
left a comment
There was a problem hiding this comment.
Looks good, approving. There is nothing to fix here on its own. Merge commit b3d251e brings in #1914's fix (1793813: cancelling the pill's picker no longer wipes the focus) and current main.
Checked:
- Read-only roles and the focus shortcuts. Tasks and Ready to publish still go through the job rules, so they stay hidden without
canChange, and Win back keeps its read wording. The other shortcuts are fine for Analyst and Agency partner roles. Site audit fixes, What to write next, Weekly report, Quality pass and Fact check all answer in the chat: a prioritised list, Before/After passages, a table to paste. The only write any of them reaches is the optionalcreate_draft, which goes through the role check and its card like any other write. The read-only test that keepsauditFixesandreportmatches that. - Brand access.
readFocusFillreads as the person. On prod,insights_competitor_daily,competitors,topics,promptsandprompt_setsare all filtered through RLS-filteredbrands, so brand scope holds. The brand id and the focus are both validated, and the CHAT_AGENTIC flag is checked. - en.json keys resolve. Help sections are under 150 words, and the article is unapproved, so the snapshot doesn't change.
focus-home.tsis pure and safe in the client bundle.
Follow-up (not blocking): readRivals pages through raw insights_competitor_daily rows and sums them in JS. On prod, the largest brand has 7,191 rows in the 14-day window: 8 sequential 1000-row pages at about 17 ms of database time each, as the person (EXPLAIN ANALYZE). Wall time is probably 0.4 to 0.7 s once round trips are counted. It runs after Home renders and only for Competitors, SEO or Product, so it isn't blocking. Still, a small RPC that groups by competitor and week would cut it to one call returning about 100 rows. PostgREST aggregates are off, and the existing competitor_aggregates_daily counts total_mentions rather than mention_answers and takes about 174 ms per week, so it isn't a drop-in.
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): 229 files and 2595 tests pass. One engine.test.ts case timed out at 5 s under parallel load and passes alone (158/158). tsc --noEmit is clean, and eslint and prettier are clean on the touched files.
# Conflicts: # help/chat/focus.md # web/src/app/[locale]/(dashboard)/dashboard/chat/_chat-page-access.ts # web/src/components/chat/chat-home.test.tsx # web/src/components/chat/chat-home.tsx
Summary
Chat W2-23a: Chat Home fits the person's focus (CHAT-24 §4, mockup
CHAT-mockup-v2.html#s-dept). Stacked on #1914, the focus picker: review and merge that first; this PR's own change is 789815d (then a merge of #1914's last commit). Web only. No migration. BehindCHAT_AGENTIC.What changes with a focus
For you now takes the picked areas' shortcuts in turn: the first of each, then the second of each…, so every picked area shows.
Start with a question: four questions from the picked areas, in turn. They are filled with the workspace's own words where it knows them:
Otherwise a question keeps its general wording.
Greeting line, only with Competitors picked: "{rival}'s mention rate rose {n} points this week." It compares
insights_competitor_dailythis week against the week before, needs a 3+ point rise, and shows only when nothing needs the person.The / menu lists the focus's skills first.
Without a focus, Home is as on main. The only addition is #1914's "Choose focus" pill.
How it's built
lib/chat/focus-home.ts(pure): each area's shortcuts and starters, the turn-by-turn merge, the fill, the greeting line and the skill order.readFocusFill(lib/actions/chat-home.ts) reads as the person, for the active brand, and only for the areas that need it.for-you-now.tsxtakes the focus shortcuts. Shortcuts with an Ansvisor skill (tasks, winback, publish, quality, report, wrongclaim) ask in that skill's words. The rest ask in plain sentences, and Chat picks the skill from its description.chatShell.home.focus.*.Next: W2-23b adds the seven focus-tagged skills and New for you (stacked on this).
Help:
help/chat/focus.mdgets "What changes on Chat Home" (approved: false).Related issue
None. Chat Wave 2 (W2-23a).
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. Give a person the focus Competitors, Product and Markets, and give the active brand a competitor whose mention rate rose 3+ points this week. A seed is available on request.focus-home,chat-home(action and component) and_chat-page-access.Checked in the browser at 1024px, light and dark, with and without a focus. 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)Full checks on 789815d: web 801 of 802 files / 8,370 tests passed, and
yarn buildpasses. Serverformat:checkand lint are clean, and 351 files / 4,987 tests pass (3 skipped). The one failing file wassubscription-guard-coverage.test.ts, the same failure as #1914 (the focus actions). It passes after merging #1914's fix (be0174c, 6/6).readFocusFillonly reads, so it adds nothing to that list.🤖 Generated with Claude Code