Skip to content

feat(traffic): add 7 / 30 / 90-day time-range picker - #481

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
Maqbool61:feat/traffic-time-range-picker
Jul 19, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
Maqbool61:feat/traffic-time-range-picker

Conversation

@Maqbool61

Copy link
Copy Markdown
Contributor

Closes #451

What

Adds a segmented 7d / 30d / 90d time-range control to the AI Traffic page header. The backend actions already accepted a days parameter — this PR wires up the missing UI so users can finally look at a month or a quarter of traffic.

Changes

web/src/app/[locale]/(dashboard)/dashboard/traffic/page.tsx — single file changed.

  • Added TIME_RANGE_OPTIONS constant and TimeRangeDays type (7 | 30 | 90).
  • New days state, defaulting to 7.
  • useEffect on brand?.id now also resets days to 7 so switching brands keeps working as before.
  • loadSummary passes days to both getTrafficSummary(brandId, days) and getTrafficTrend(brandId, days); days added to the useCallback dep array so it reloads on change.
  • loadLogs passes days inside opts; days added to its dep array.
  • New handleDaysChange callback — sets days and resets page to 0.
  • Page header refactored to justify-between flex row; picker sits right-aligned using the same flex rounded-md border p-0.5 pattern as _fanout-tab.tsx.
  • Trend chart title is now AI Referral Trend — Last {days} Days.
  • Visits KPI fallback sublabel is now `last ${days} days` instead of the hardcoded "last 7 days".

Acceptance criteria

  • Switching between 7d / 30d / 90d reloads KPIs, both charts and both tables with the selected window.
  • The trend chart title and KPI sublabels reflect the selected range.
  • Default remains 7 days; switching brands resets back to 7d and keeps working as before.

Checks

yarn typecheck   ✓  Done (0 errors)
yarn lint        ✓  0 errors, 9 pre-existing warnings (none introduced by this PR)
yarn format:check ✓  All matched files use Prettier code style!

@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.

Verified against main: all three actions already take days, the delta scales with the window, and page reset / brand reset behave correctly. Thanks for wiring this up cleanly!

@gkhngyk
gkhngyk merged commit 2ae96c9 into ansvisor:main Jul 19, 2026
4 checks passed
@Maqbool61
Maqbool61 deleted the feat/traffic-time-range-picker branch July 19, 2026 16:04
gkhngyk pushed a commit that referenced this pull request Nov 16, 2026
…closest" ones

Chat could not answer "what is AC-481?" when AC-481 was on screen: it had no
way to read an action by its code, only a page of the list ranked by priority
(list_action_center_tasks) or one action by its id (get_action). AC-481 was
past the first page of 50, so Chat said it didn't exist and listed others.

- list_action_center_tasks takes `codes`: every code of a message in one read
  ("AC-481", "AC 481", "ac481", "#481", "481", "AC-07"). It matches as the
  Actions list's search and the actions/code route do (matchesActionCode):
  the brand's number or the old global number. Each row says whether the code
  is its code or its previous code; a code that names two actions returns
  both; codes no action has come back in not_found. Every status, never a
  deleted action, this brand of the caller's organization only (brandAllowed
  and an inner join on brands.organization_id).
- A limit sent with codes no longer cuts the rows (scope.ts NAMED_ROWS).
- The tool descriptions and ACTION_NAME_RULES: read the code first; a code not
  found is "not found in this brand, codes are per brand", never "the
  closest"; never "doesn't exist" because a page didn't show it.
- Help: "Ask about your actions" says you can ask by code.
- Eval: "AC 481 ve AC-63 nedir" on a brand with 55 open actions, AC-481 past
  the first page; it must read both by code, name both by title and code, and
  name no other action in their place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
gkhngyk pushed a commit that referenced this pull request Nov 16, 2026
…losest" ones

An MCP client asked "what is AC-481?" could only page list_actions by
priority (50 rows by default, 200 at most), so an action past the page
looked missing and the client could answer with other actions instead.
Chat got the same lookup in #2445; MCP now reads codes the same way.

- list_actions takes `codes` (up to 10: "AC-481", "AC 481", "ac481",
  "#481", "481", "AC-07"). With codes it answers from Chat's read
  (listActionsByCodeFor): the same query, rows and note, no second query.
  It matches the brand's number or the old global number, says per row
  whether that is its code or its previous code (previous_ref), returns
  both actions for a code that names two, reads every status but never a
  deleted action, and lists codes the brand doesn't have in not_found
  with "codes are per brand". status, category, sort and limit don't
  apply beside codes.
- Scope as before: brandAllowed (organization and brand access), the
  brand_id filter and an inner join on the brand's organization. A code
  of another brand or workspace is not found; only parsed numbers reach
  the filter.
- The list_actions description: read the code first; a code not found
  means this brand has no action with it; never offer the closest
  actions; never say an action doesn't exist because a page didn't show
  it. get_action's action_id says where a code's id comes from.
- The REST mirror (/api/mcp/actions) is unchanged.
- Docs: the MCP guide's list_actions row. Help: one example line in the
  MCP article's "What you can ask".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
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.

Traffic: add a 7 / 30 / 90-day time-range picker

2 participants