Repository navigation
feat(chat): open pages from Chat with a route registry and a rule-based router - #1807
Conversation
…l, with a navigation card
Chat Wave 1 W1-28 (CHAT-19 §2, §6; CHAT-20 §9 row 1):
- Route registry (lib/chat/routes.ts): every page Chat can open, made
from the live sidebar (config/dashboard.ts, its items and their
submenus) and Settings' sections, named as the sidebar and Settings
name them, with the plan feature each needs, other words people use for
it, and the filters its address keeps (range and platform where the
page reads them). Chat's own page isn't one.
- Rules-based router (routeRequest): a plain "open / show / take me to /
go to {page} [for {platform}] [{range}]" gives the page and its filters
with no model and no AI usage: "Open Visibility for Perplexity, last 30
days" is /dashboard/insights?range=30d&model=perplexity-web. It answers
only when it understood every word: a question, a filter the page
doesn't keep ("drafts under Quality 60") or anything left over goes to
the model.
- open_page (registry row, area navigation, C0): for what the model
routes; only pages the plan opens (a locked one names the plan that
has it) and the plan's platforms as a filter; it reads the plan and
nothing else.
- Navigation card (components/chat/navigation-card.tsx): the page, its
filters by name, "Filters set for you. This chat stays open in the side
panel.", "Navigation only · no AI usage" and Go to page.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…en_page
Review fixes for the route registry and open_page.
- routes.ts read ALL_DATE_PRESETS from the date range control, a 'use
client' module. On the server, a client module's exports are client
references, not values, so every Chat turn (engine → registry → open_page
→ routes) would fail. The presets now live in config/date-presets.ts, and
the control re-exports them. traffic-range.ts reads them there too.
- plan-row.test.ts gains the other direction of its import walk: a shared
module (src/lib, src/config) reads no value from a 'use client' file.
- open_page's platform is one of the tracked platform ids (z.enum), and the
pages' platform filter takes only those. A wrong slug no longer opens an
empty page on plans without allowedScrapers.
- The registry lists only the Settings sections this install shows: a
self-hosted one has no Billing or AI Providers.
- Competitors needs competitor_tracking.
- The Action Center tabs' and Brands' names come from en.json.
- Two pages matched by phrases of the same length ("open plan": Content ›
Plan or Billing, "open insights") are the model's to ask about.
- The navigation card says "no AI usage" only when the rules-based router
answered (ruleRouted).
- ORG_PLAN_COLUMNS comes from guards/plan-row.
- Tests: ties, //evil.com and javascript: addresses, the router with a
plan lock, the platform enum, and self-hosted Settings.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Insights' model filter holds the answers' model slugs, not platform ids, so model=chatgpt-web opened an empty page. Insights keeps only its range; a platform request for it goes to the model. Claude-Session: https://claude.ai/code/session_0121amRjX7UFrgmGELAtkc7A
gkhngyk
left a comment
There was a problem hiding this comment.
Looks good with 19b2d17 (one commit on this branch). FILTERS.insights set the platform id as ?model=, but Insights' model filter takes the answers' model slugs (prompt_results.model_used, e.g. gpt-5-…), so "open visibility for ChatGPT" opened an empty Insights page. Insights now keeps only its range: the router hands "Open Visibility for Perplexity…" to the model, and open_page leaves the platform out of filters. The platform tests now use Citations, whose platform param does take the scraper id, and the two new cases fail without the commit. A real Insights platform filter (platform id → that family's slugs) could come later.
Checked, fine
- Only in-app links:
routeByIdmatches exact registry ids,hrefWithFilterssets only allow-listed values, and the card uses the i18nLink. openPageForreads only the caller's organization plan columns. Plan-locked routes come backlockedwithneeds, platforms outside the plan are dropped and reported, and self-hosted drops Billing and AI Providers.- Reached only through the engine behind
CHAT_AGENTIC, no MCP tool. It's a read with no brand data, so the read-only gate and demo guard aren't needed. plan-row.test.ts(with its new reverse check) andnext buildpass. Chat, MCP, guards, config and filter tests: 707 pass.tsc, eslint and prettier are clean.
Non-blocking
menu-accessis listed for every role, while Settings shows it only to admins and the managers they allow. Shopping'srequiresBrandPrefisn't considered either.- When
routeRequestis wired in, route it throughopenPageFor, since the router alone does no plan check. - The tool
open_pageshares its name with theopen_pagestep kind in #1833–#1835 (external pages). Worth keeping them apart in labels.
Merge: clean on main, no migrations. Additive conflicts with #1800 and #1819–#1822 in registry/tools.ts, tools.test.ts and en.json chatTools: keep both sides.
Competitors is back on the sidebar (ansvisor#1809), so the registry would list it twice: from the sidebar and from the pages Chat adds.
gkhngyk
left a comment
There was a problem hiding this comment.
Still good with 97658d7, one more commit for #1809. #1809 puts Competitors back on the sidebar, and this PR lists it as an extra page the sidebar doesn't have, so with both merged the registry lists it twice and routes.test.ts › points every route at a page of the app, once fails. The commit skips an extra page whose address the sidebar already has, so it works in either merge order. routes-sidebar.test.ts fails without it. On main with #1809 and this branch: 92 files, 1,008 tests pass, plus plan-row.test.ts and tsc.
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.
Summary
Chat Wave 1, W1-28: opening pages from Chat (CHAT-19 §2, §6), behind
CHAT_AGENTIC.lib/chat/routes.ts):config/dashboard.tsdashboardNav) andSETTINGS_SECTIONS, with the sidebar's names (nav.*,settings.*), plus Action Center Signals / KPIs / History, Competitors and Brands.range/model;preset/platform;range;preset.hasSettingsSection.routeRequest: a rule-based router that runs before the model, with no AI usage.open_page:registry/navigation.ts; areanavigation, C0, read.openPageFor: reads only the organization row. It returns{ locked, needs }without the plan feature, and drops a platform the plan doesn't read.z.enumof the 8 answer engines.components/chat/navigation-card.tsx: the page ("Prompts › Tracked Prompts"), filter chips, "Filters set for you…", Go to page. "Navigation only · no AI usage" shows only for rule-routed turns (ruleRouted). The card isn't wired into the shell yet; that comes with Wave 1's shell work.Review round (42391e4)
routes.tsreadALL_DATE_PRESETSfrom'use client'date-range-filter.tsx. On the server that export is a client reference, so/api/chat/runswould 500.config/date-presets.ts, whichdate-range-filterre-exports;traffic-range.tsmoved to it too.plan-row.test.ts(fix(settings): keep the server Supabase client out of Roles & access, so the web build passes #1796) gets the reverse check: no shared module insrc/liborsrc/configreads a value from a client component. It caught this exact import before the fix.en.jsonviacreateTranslator.competitor_tracking.ORG_PLAN_COLUMNScomes fromplan-row.//evil.com,https://evil.com,javascript:,../login), the router with the plan lock, the platform enum, self-hosted Settings.Related issue
Part of Chat (CHAT-19, Wave 1).
Type of change
feat— New featureHow to test
cd web && yarn vitest run src/lib/chat src/components/chat src/lib/guards src/config:yarn buildpasses (73/73 static pages). Its TypeScript step neededNODE_OPTIONS=--max-old-space-size=4096on an 8 GB machine.Merging with #1800 (W1-16): additive conflicts in
registry/tools.ts,tools.test.tsanden.jsonchatTools. Keep both sides.Checklist
plan-row.test.ts's import walk took 8.7 s under load against the 5 s default; it passes alone in 2 s)🤖 Generated with Claude Code