feat(client): Agent Control settings page for the billing exception agent#518
Conversation
…gent Add the client surface for the billing exception agent's per-org control, consuming the GraphQL operations already generated in @trenova/graphql: - lib/graphql/agent-control.ts: fetch/update wrappers over the AgentControlSettings query and UpdateAgentControl mutation (fragment unmasked via getFragmentData, mirroring the reports pattern). - types/agent-control.ts: zod schema for the form (shadow mode, enablement, decision timeout bounds). - routes/agent-control: admin settings page + form mirroring the cost/dash control pattern (SwitchField/NumberField/FormSaveDock, useApiMutation, suspense query). Surfaces a warning when shadow mode hides proposals. - Register the /admin/agent-control route and Organization nav entry. - Add the agent_run/agent_proposal/agent_exception/agent_control resources to the shared client permission map. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Su3U8smvJVBSF4Rs9dkVTw
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
trenova | 6f66df4 | Jul 24 2026, 04:55 PM |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughAdds a protected Agent Control admin page with navigation, typed GraphQL read/update operations, validated billing-agent settings, conditional warnings, and query refresh behavior. ChangesAgent Control configuration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Admin
participant AgentControlPage
participant AgentControlForm
participant GraphQLAPI
Admin->>AgentControlPage: open /admin/agent-control
AgentControlPage->>AgentControlForm: render
AgentControlForm->>GraphQLAPI: fetchAgentControl()
GraphQLAPI-->>AgentControlForm: current settings
Admin->>AgentControlForm: submit validated settings
AgentControlForm->>GraphQLAPI: updateAgentControl(input)
GraphQLAPI-->>AgentControlForm: updated settings
AgentControlForm-->>Admin: show success toast
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description
Adds the client-side surface for the billing exception agent's per-organization control. The backend
AgentControlentity, GraphQL API, and the@trenova/graphqloperations already landed onmaster, but there was no UI to actually read or change these settings — this PR builds that page so an operator can enable the agent, toggle shadow mode, and set the decision timeout without hand-writing GraphQL.It mirrors the existing
cost-control/dash-controlsettings pattern end to end (suspense query → react-hook-form + zod →useApiMutation→FormSaveDock). The form surfaces a warning callout when shadow mode is on, since that's the state where runs execute but proposals are intentionally never surfaced.Related Issue or Discussion
Follow-up to the merged billing-exception-agent work (#517). Requested directly by the maintainer.
Type of Change
Scope
client/apps/web/src/routes/agent-control/— admin settings page + form (shadow mode, enablement, decision timeout; shadow-mode warning callout)client/apps/web/src/lib/graphql/agent-control.ts— fetch/update wrappers over theAgentControlSettingsquery andUpdateAgentControlmutation (fragment unmasked viagetFragmentData)client/apps/web/src/types/agent-control.ts— zod form schema (timeout bounded 5 min–7 days)client/apps/web/src/router.tsx—/admin/agent-controlroute, gated onagent_control:readclient/apps/web/src/config/navigation.config.ts— "Agent Control" entry under the Organization groupclient/packages/shared/src/types/permission.ts— adds theagent_run/agent_proposal/agent_exception/agent_controlresources to the client permission mapValidation
cd client && pnpm --filter @trenova/web typecheck— passescd client && pnpm --filter @trenova/web lint— no errors/warnings in the new files (pre-existingbetter-tailwindcsswarnings elsewhere are unrelated)cd client && pnpm build— not run in this environment; typecheck covers the type surfacecd services/tmschecks — n/a, this PR is client-only (no Go changes)Screenshots or Recordings
Not captured — no running app/browser was available in this environment. The page reuses the shared settings-form primitives (
Card,SwitchField,NumberField,FormSaveDock), so it renders consistently with the existing Cost/Dash/Settlement Control pages.Deployment Notes
agent_control:read; users need that grant to see the page andagent_control:updateto save.AgentControlGraphQL API; no new API surface introduced here.Checklist
AGENTS.md,CLAUDE.md, and existing repository patterns.🤖 Generated with Claude Code
Generated by Claude Code
Summary by CodeRabbit