Skip to content

fix(mcp): surface backend errors in Agent UI MCP callers + stop session nav oscillation#1758

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-1755
Draft

fix(mcp): surface backend errors in Agent UI MCP callers + stop session nav oscillation#1758
github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-1755

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

The #1750 review landed several findings after merge, so these regressions are currently on main. Two of them violate the "No Silent Fallbacks" rule: after #1750 switched MCP boundary errors to the {"status":"error","detail":...} envelope, get_messages and index_document still keyed on the old {"error"} shape — so a backend failure (e.g. a 404 for a missing session) silently fell through to an empty {"messages":[],"total":0} payload, and a failed session-document attach was reported as a successful link. Both now detect the envelope and fail loudly. The third is a 🔴 UI regression: the App.tsx URL-hash nav guard re-ran on every currentSessionId change, read a stale 7-char short hash (which never equals the full UUID), and scheduled a ~500ms bounce that could ping-pong sessions — breaking the very MCP→UI activation flow #1750 added. The guard now runs once on mount.

Also folds in the review's minor items: delete_session and the screenshot tool now use the same structured envelope, and the unused emit_set_active_session shim is removed. The tautological App.test.tsx (literal-vs-literal assertions that never rendered App) is replaced with a real render-based regression test for the nav guard.

Closes #1755

Test plan

  • python -m pytest tests/unit/test_agent_ui_mcp.py — 13 passed (incl. new get_messages silent-fallback and index_document false-success regression tests)
  • python -m pytest tests/unit/ — 5231 passed (1 pre-existing, unrelated test_memory_router FAISS failure also present on main)
  • python util/lint.py --flake8 / --black / --isort clean
  • cd src/gaia/apps/webui && npm run test — runs the new App.test.tsx nav-guard test (vitest; node_modules not available in this job)
  • Live A→B session switch: open the Agent UI, activate session A via the MCP bridge, switch to B in the sidebar, confirm it stays on B (no bounce back to A) and B's messages aren't wiped

⚠️ Needs manual validation — the automated checks here confirm no Python regression but can't exercise the frontend. A maintainer should run npm run test in src/gaia/apps/webui and do the live A→B session-switch check above before merging.

…on nav oscillation

The #1750 envelope change switched boundary errors to {"status":"error"},
but get_messages and index_document still keyed on the legacy {"error"}
shape — so a backend failure (e.g. 404) silently fell through to an empty
{"messages":[],"total":0} payload, and a failed session-document attach was
reported as linked. Both now detect the structured envelope via _is_error and
fail loudly. delete_session and the screenshot tool are normalized to the same
envelope, and the unused emit_set_active_session shim is removed.

App.tsx: the URL-hash nav guard depended on currentSessionId, so it re-fired on
every session switch, read a stale short hash, and scheduled a ~500ms bounce
that could ping-pong A<->B — breaking the MCP->UI activation flow #1750 added.
The guard now runs once on mount and reads currentSessionId fresh inside the
timer. Replaces the tautological App.test.tsx with a real render-based
regression test for the guard.

Closes #1755
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.

Post-merge fixes for #1750 review: error-envelope caller breakage + session-nav oscillation

0 participants