Skip to content

fix(usage): wire agent exclusions through usage filters#972

Open
prateek wants to merge 1 commit into
kenn-io:mainfrom
prateek:agent-exclude-fix
Open

fix(usage): wire agent exclusions through usage filters#972
prateek wants to merge 1 commit into
kenn-io:mainfrom
prateek:agent-exclude-fix

Conversation

@prateek

@prateek prateek commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Fixes the pre-existing silent no-op where clicking an agent in Usage attribution updated local exclusion state, but the next usage requests did not send excludeAgent. The store now includes agent exclusions in the shared request params and counts them in hasActiveFilters, so the API sees the same filter state the UI shows.

The Usage toolbar also gets the Agent dropdown next to Project and Model. It uses the existing dropdown pattern, which makes agent exclusions visible and reversible without relying on attribution-row clicks. This stays scoped to Usage agent filtering and does not depend on the branch-dimension work.

Agent dropdown on the usage toolbar (synthetic data)

Reviewers should start with frontend/src/lib/stores/usage.svelte.ts; UsagePage.svelte is the toolbar wiring, and the added component/store tests cover the request params plus the attribution-click path.

Fixes #976.

@roborev-ci

roborev-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

roborev: Combined Review (fb5d625)

Medium issue found.

Medium

  • frontend/src/lib/components/usage/UsagePage.svelte:177
    Agent exclusions are sent to the usage API, but /usage URL hydration still ignores exclude_agent and never clears usage.excludedAgents for deep links. Because excludedAgents is restored from localStorage, opening a shared URL with another filter, such as ?model=..., can silently keep excluding a previously hidden agent and show incorrect usage results.
    Fix: Add exclude_agent to the usage URL keys, hydrate usage.excludedAgents from params["exclude_agent"] ?? "", emit it from buildUsageUrlParams, and update the URL-param tests.

Reviewers: 2 done | Synthesis: codex, 6s | Total: 4m35s

@prateek prateek marked this pull request as ready for review July 3, 2026 07:30
@roborev-ci

roborev-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

roborev: Combined Review (d24a85e)

No Medium, High, or Critical findings were reported.

Review 1 only reported a Low-severity URL persistence issue, which is omitted per instructions. Review 2 found no issues.


Reviewers: 2 done | Synthesis: codex, 7s | Total: 3m15s

@prateek prateek changed the title fix(usage): send agent exclusions to the API and surface the Agent dropdown fix(usage): wire agent exclusions through usage filters Jul 3, 2026
@prateek prateek force-pushed the agent-exclude-fix branch from d24a85e to 55469df Compare July 3, 2026 08:00
@prateek

prateek commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the automated review finding: agent exclusions now round-trip through the URL (exclude_agent param), matching project exclusions, so a shared or reloaded /usage URL preserves them.

@roborev-ci

roborev-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

roborev: Combined Review (55469df)

Summary verdict: One medium issue needs fixing before merge.

Medium

  • frontend/src/lib/components/usage/UsagePage.svelte:52: The new Agent dropdown is backed by sessions.agents, but UsagePage never loads that metadata. On a direct /usage visit, the list can remain empty unless another component has already called sessions.loadAgents() or a sync invalidation happened. Load agent metadata when the usage page mounts, or make the dropdown trigger sessions.loadAgents() before opening.

Reviewers: 2 done | Synthesis: codex, 6s | Total: 3m26s

@prateek prateek force-pushed the agent-exclude-fix branch from 55469df to cd64f5f Compare July 3, 2026 08:23
@prateek

prateek commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the round-2 finding: UsagePage now calls sessions.loadAgents() on mount, so the Agent dropdown is populated on a direct /usage visit instead of depending on the sidebar having loaded agent metadata first. Covered by a mount test.

@roborev-ci

roborev-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

roborev: Combined Review (cd64f5f)

Medium issue found: active filter clearing does not clear agent exclusions.

Medium

  • frontend/src/lib/components/usage/UsagePage.svelte:451
    Agent exclusions are now active usage filters, but SessionActiveFilters is still only wired for model/project usage filters. If a user excludes an agent and then uses the active-filters “Clear all” control, usage.excludedAgents remains set, so usage data stays filtered after the UI action implies all filters were cleared.

    Fix: Add agent filter props/handlers to SessionActiveFilters and pass usage.excludedAgents from UsagePage, including onRemoveAgent and onClearAgents={() => usage.selectAllAgents()} in the clear-all path.


Reviewers: 2 done | Synthesis: codex, 7s | Total: 5m23s

…opdown

Clicking an Agent tile in the Attribution panel updated excludedAgents
locally but baseParams() never copied it into the outgoing request, so
the exclusion was a silent no-op; hasActiveFilters ignored it too. There
was also no Agent FilterDropdown on the Usage toolbar, so hidden agents
had no visible surface at all. Wire excludeAgent into baseParams and
hasActiveFilters, and add the Agent dropdown mirroring Project's.
@prateek prateek force-pushed the agent-exclude-fix branch from cd64f5f to cbe9a6a Compare July 3, 2026 09:11
@prateek

prateek commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the round-3 finding: SessionActiveFilters gained an onClearAgents hook invoked by Clear all, and UsagePage wires it to usage.selectAllAgents(), so agent exclusions now reset with the rest. Kept to the clear-all hook to match how excluded projects are handled on this surface (they don't render chips here either); per-exclusion chips would be a separate change across both dimensions.

@roborev-ci

roborev-ci Bot commented Jul 3, 2026

Copy link
Copy Markdown

roborev: Combined Review (cbe9a6a)

No issues found.


Reviewers: 2 done | Synthesis: codex | Total: 6m39s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Usage page agent exclusions are a silent no-op

1 participant