Repository navigation
fix(frontend): /m says the agent list is admin-only instead of "Couldn't load agents" (#3041) - #3071
Conversation
…n't load agents" (#3041) GET /api/ops/fleet/status is admin-gated, so every role below admin got a 403, and the Agents tab rendered the generic failed state with a retry that could never succeed. A permission boundary was being reported as a transient failure. - A 403 from the fleet endpoint sets fleetAdminOnly. The Agents tab then shows "The agent list is admin-only", with one next action (Open the Queue) and no retry. The System tab's fleet summary, which uses the same endpoint, shows the admin-only line instead of "Couldn't load fleet health". - The 15s poll stops re-asking once forbidden. A manual refresh still re-checks, so a role granted in the meantime shows up. - Other failures are unchanged: they still render LoadFailed with retry, or the stale banner. Admins see the tab exactly as before. Execution stats stay decorative (the allSettled split is kept). - Non-admins keep the Agents tab: the server's 403 is the authority, not a client-side role guess. Mounted vitest covers: the 403 notice with no failed state or retry, the Queue action, the poll stopping, the System tab, a 500 still failing, and the admin path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
webmixgamer
left a comment
There was a problem hiding this comment.
/review: #3071
Verdict: no critical findings, mergeable as is. There are 4 informational findings. I1 is a real bug with a one-line fix, and I'd suggest fixing it before merge.
Scope: clean. The System-tab fleet summary goes beyond #3041, but it calls the same endpoint and the PR body says so.
Acceptance criteria (#3041)
| Criterion | Status | Evidence |
|---|---|---|
| A 403 shows an honest admin-only notice with no retry | ✅ done | MobileAdmin.vue:103-107, :826-832 |
| Admins see the tab as before | ✅ done | the new branch falls through when the flag is false; "an admin sees the list" test |
| A mounted jsdom test covers the non-admin case | ✅ done | new spec, jsdom with real mounts, no source-text matching |
| Decide whether non-admins see the Agents tab | ✅ done | kept visible; reasoning is in the PR body |
Keep execution stats decorative (allSettled split) |
✅ done | :818-822 unchanged |
| Manual check as a non-admin in a browser | still unticked in the Test Plan |
Test coverage and mutations
At 7006df30, all 5 specs that touch /m pass (100/100), and so do the colour, loading-gate and source-text ratchets.
Main check: reverting MobileAdmin.vue to the merge-base turns 4 of the 6 new tests red, which matches the PR's claim. The other two (admin, 500) pass either way, as intended.
I then removed one piece of the fix at a time:
| Piece removed | Tests that went red | Verdict |
|---|---|---|
403 branch in fetchAgents (:826-832) |
4 | ✅ covered |
Agents poll guard (:1505) |
poll test | ✅ covered |
System-tab notice (:440-442) |
System test | ✅ covered |
Flag reset when fetchAgents succeeds (:834) |
none | ❌ the "role granted meanwhile" claim is untested |
Flag reset when fetchFleetHealth succeeds (:926) |
none | ❌ no test runs this line |
403 branch in fetchFleetHealth (:931-935) |
none | ❌ no test runs this line (the flag is already set on mount) |
System poll guard (:1507) |
none | ❌ untested |
Informational findings
I1 — "Open the Queue" can open Alerts instead (confidence 9, reproduced)
- The button at
MobileAdmin.vue:106only switches the main tab:@click="activeTab = 'ops'". - Which sub-tab shows is separate state (
activeOpsTab,:665), changed only by the sub-tab buttons (:207). - A test that goes Ops → Alerts → Agents and then taps "Open the Queue" ends with the active sub-tab
"Alerts". - Test 2 misses it because it never leaves the default sub-tab.
Fix: @click="activeTab = 'ops'; activeOpsTab = 'queue'". This test, using the spec's own harness, fails on the current head:
it('Open the Queue lands on the Queue sub-tab even after Alerts was viewed', async () => {
const w = await mountView({ fleet: () => Promise.reject(forbidden()) })
const tabBtns = w.findAll('.tab-bar .tab-item')
await tabBtns[1].trigger('click'); await flushPromises()
await w.findAll('.sub-tab').find(b => b.text().startsWith('Alerts')).trigger('click'); await flushPromises()
await tabBtns[0].trigger('click'); await flushPromises()
await w.find('[data-testid="agents-admin-only-open-queue"]').trigger('click'); await flushPromises()
expect(w.find('.sub-tab.active').text().startsWith('Queue')).toBe(true)
})I2 — Four parts of the fix have no test (confidence 9, from the mutation table)
- The PR body says "a manual refresh still re-checks, so a role granted in the meantime shows up".
- Deleting the reset at
:834breaks exactly that: the notice stays until a page reload, and every test stays green. - This test passes on the head and goes red with that reset deleted:
it('a role granted meanwhile shows up on manual refresh', async () => {
let n = 0
const w = await mountView({ fleet: () => (n++ === 0 ? Promise.reject(forbidden())
: Promise.resolve({ data: { agents: [{ name: 'agent-a', status: 'running' }], summary: { total: 1, running: 1, stopped: 0, high_context: 0 } } })) })
expect(w.find('[data-testid="agents-admin-only"]').exists()).toBe(true)
await w.find('.header-actions .header-btn').trigger('click'); await flushPromises()
expect(w.find('[data-testid="agents-admin-only"]').exists()).toBe(false)
expect(w.text()).toContain('agent-a')
})Two more tests would cover the rest:
- a System-tab poll check with fake timers (
tab: 'system', no fleet calls after 31 s); - a
fetchFleetHealth403 while the flag is still false (e.g. the first fetch was a 500), refreshed from the System tab.
I3 — The System tab still offers four admin-only actions (confidence 7)
- The tab now says "Fleet health is admin-only", but Emergency Stop, Fleet Restart, Pause Schedules and Resume Schedules (
:477-503) stay enabled below it. - All four endpoints require an admin (
routers/ops.py:158, 263, 300, 347). - A non-admin goes through a confirm dialog and then gets "Admin access required". That message is honest, but it's a dead end.
Suggestion: disable or hide the Actions section while the flag is set, or file a follow-up. It's outside #3041's scope, so it shouldn't block.
I4 — "The agent list is admin-only" says too much (confidence 6)
- A creator's own agents aren't admin-only.
GET /api/agentsonly needs a signed-in user (routers/agents.py:136-141), and the desktop dashboard lists them. - Only this fleet-wide view is admin-only.
Suggestion: copy along the lines of "The fleet list is admin-only on mobile…", optionally pointing to the desktop dashboard.
Checked and clean
- SQL / data, concurrency, credentials, backend auth: frontend-only diff. Both functions write the flag from the same endpoint's answer, so they can't disagree.
- Is 403 always "not an admin"? For a signed-in browser session, yes. Suspended users get a 401; the other 403s on this path are for non-browser keys (
dependencies.pyget_current_user/assert_admin). - The error shape the fix relies on:
utils/boundedHttp.jspasses axios errors through untouched, soe.response.statusis really there. The test's mock isn't hiding a mismatch. - Other callers:
/api/ops/fleet/statushas only two frontend callers, and both are fixed. - Is the Queue a real next step? Yes. The queue list only needs a signed-in user and is filtered to the agents you can access (
routers/operator_queue.py:114-128). - Design system: no new colours (the button reuses
chat-open-btn); the ratchets pass; the Agents notice gives one next action. - Docs (optional):
docs/memory/feature-flows/mobile-admin-pwa.md:89describes/m's polling and page states but not the admin-only state or the paused poll. Bug fixes only require the commit message.
🤖 Generated with Claude Code
…ions, honest copy, tests - "Open the Queue" now always lands on the Queue sub-tab (was: whichever Ops sub-tab was last viewed, e.g. Alerts). - The System tab hides the four admin-gated fleet actions for a non-admin instead of offering a confirm-then-403 dead end. - Copy: "The fleet list is admin-only on mobile" — a creator's own agents are not admin-only; point at the desktop dashboard. - Tests for the previously unexercised pieces: manual refresh clears the flag (both fetchers), fetchFleetHealth's own 403 branch, the System poll guard, the actions visibility, the sub-tab landing. Each piece mutation-checked red. - Feature flow: the admin-only state and the paused poll. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks @webmixgamer. All four findings are addressed in a23bbfc.
Mutation check: I removed each piece one at a time and each turned exactly one test red. The pieces were the sub-tab reset, the flag reset in both fetchers, the The manual browser check as a non-admin is still open in the Test Plan. |
webmixgamer
left a comment
There was a problem hiding this comment.
/validate-pr: #3071 (re-run on a23bbfc83)
Recommendation: APPROVE. The fix-up commit addresses all four findings from the /review above, and I verified each one against the code. Lane: B (standard code; no schema changes).
Summary
| Category | Status | Notes |
|---|---|---|
| Commit messages | ✅ | Both commits are fix(frontend): with bodies that explain what changed and why |
| Base branch / size | ✅ | dev; 3 files |
| Issue auto-promotion | ✅ | Fixes #3041 (same repo) moves the issue to status-in-dev on merge |
| Issue labels | ✅ | #3041 is priority-p3, type-bug, theme-ui-ux |
| Requirements / architecture | ➖ | Bug fix; frontend only, no API or schema change |
| Feature flows | ✅ | mobile-admin-pwa.md now covers the admin-only state, the paused poll and the hidden Actions |
| Security / hygiene | ✅ | No keys, emails, IPs, secrets, .env or credential files; no symlinks, mode changes or host paths; nothing flagged by the enterprise-disclosure check |
| Packaging | ➖ | No backend package, compose or environment-variable changes |
| Structural review | ✅ | /review is posted above; all four of its findings are addressed |
| Merge gate | ✅ | All checks that can block are green on a23bbfc83, and dev is green |
| Test adequacy | ✅ | The regression test names #3041; each part of the fix has a test that goes red when that part is removed (below) |
| Code quality | ✅ | Focused change that follows the file's loading-state pattern; no new colours; check:tokens OK |
| Requirements trace | ✅ | All four #3041 acceptance criteria are met |
Review findings, re-checked
- I1:
openQueue()setsactiveTab = 'ops'andactiveOpsTab = 'queue'. The Ops → Alerts → Agents test covers it and goes red without the sub-tab reset. - I2: every previously untested part now has a test that goes red when that part is removed (table below).
- I3: the Actions section has
v-if="!fleetAdminOnly". Both directions are pinned: removing the guard turns the non-admin test red, and inverting it turns the non-admin and admin tests red. - I4: the copy now reads "The fleet list is admin-only on mobile" and points to the desktop dashboard.
Test coverage (reproduced independently)
The spec has 13 tests, all passing. Reverting MobileAdmin.vue to the merge-base turns 11 of 13 red; the 2 that stay green (500 case, admin path) cover paths the fix doesn't change.
Removing one piece at a time:
| Piece removed | Tests that went red |
|---|---|
403 branch in fetchAgents |
9 |
| Agents poll guard | 1 |
| System poll guard | 1 |
Flag reset in fetchAgents |
1 |
Flag reset in fetchFleetHealth |
1 |
403 branch in fetchFleetHealth |
1 |
| System notice | 3 |
| Agents notice | 4 |
Sub-tab reset in openQueue |
1 |
v-if on Actions (removed / inverted) |
1 / 2 |
The author's claim that each of the six pieces they listed turns exactly one test red holds.
Against current dev: merged in memory onto e87163125, the merge is clean. The full frontend unit suite passes (182 files, 3731 tests); the only exceptions are roomComposerChain and roomStopWork, which can't load on my machine because a local package is missing. They fail the same way on plain dev, and this PR doesn't touch them. check:tokens is OK.
Non-blocking
- PR body is out of date: the Test Plan still says "6/6" (now 13), and the Changes section doesn't mention that the System Actions are hidden for non-admins. Worth refreshing before the squash merge, since the squash commit carries this text.
- Manual check: the check as a non-admin in a browser is still unticked. Consider an eyeball before or right after merge.
- Brief flash of the Actions (low confidence): the Actions section renders until the first fleet fetch answers 403. A non-admin opening
/m?tab=systemdirectly may see it for a moment before it disappears. No action needed unless it shows up in the eyeball.
🤖 Generated with Claude Code
Summary
/m, a non-admin session got a 403 from the admin-gatedGET /api/ops/fleet/status, and the Agents tab rendered "Couldn't load agents" with a retry that can never succeed. The Agents tab now shows an admin-only notice instead: what it means, plus one next action (Open the Queue), and no retry control.Changes
src/frontend/src/views/MobileAdmin.vue: thefleetAdminOnlyflag, set on a 403 infetchAgentsandfetchFleetHealthand cleared on success; admin-only arms at the head of both branch chains; the poll guard. The button reuses the file's existingchat-open-btnstyle, so no new colours are added.src/frontend/tests/unit/mobileAdminAgentsAdminOnly.spec.js(new, mounted, jsdom): six cases.Test Plan
npm run test:unit: 177 files, 3706 tests passed, including the raw-colour and loading-gate ratchets.npm run check:tokensOK;npm run buildOK./m, and check the Agents and System tabs in the browser. Not done here.Fixes #3041
🤖 Generated with Claude Code