Skip to content

fix(desktop): bump backend contract so profile-routing version skew is surfaced - #40017

Closed
OutThisLife wants to merge 1 commit into
mainfrom
bb/backend-contract-bump-profile-routing
Closed

fix(desktop): bump backend contract so profile-routing version skew is surfaced#40017
OutThisLife wants to merge 1 commit into
mainfrom
bb/backend-contract-bump-profile-routing

Conversation

@OutThisLife

@OutThisLife OutThisLife commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

A "still broken after updating" report turned out to be version skew, not a code bug — and the real lesson is that nothing warned the user.

His desktop app was on #39993, but his backend runs on a separate VM still on #39991 (pre-fix). The per-session profile fixes (#39921/#39993) live in tui_gateway/server.py — the backend. He updated the desktop; the VM's Hermes stayed old. So the desktop dutifully sent profile: S on session.create, the old backend ignored it, and new chats silently landed in the launch (default/"A") profile — exactly the reported symptom.

Why it reproduced for nobody on the team: we all test desktop + backend on one machine, where a single update covers both. Remote/VM users update the two halves independently.

Root cause of the silent failure

The desktop already has a skew guard — reportBackendContract() shows a "Backend out of date" toast with one-click update when the backend reports an older desktop_contract. But when #39921/#39993 changed the WS protocol (added profile to session.create/session.resume), neither contract constant was bumped. Both stayed at 1, so a profile-routing-aware desktop happily drove a profile-blind backend with no warning.

Fix

Bump the GUI↔backend contract to 2 on both sides:

  • tui_gateway/server.py: DESKTOP_BACKEND_CONTRACT = 2 (+ version-history comment).
  • apps/desktop/src/store/updates.ts: REQUIRED_BACKEND_CONTRACT = 2.

Now a #39993+ desktop pointed at a pre-#39921 backend sees contract 1 < required 2 → the existing "Backend out of date" warning fires (with one-click align) instead of silently misrouting sessions.

Notes

  • No behavior change when desktop and backend are updated together (single-machine — the 99% case).
  • The toast copy ("Your Hermes backend is older than this desktop build…") already points at the backend, which is correct for the remote-VM case. Refining it with remote-specific guidance is a separate polish.
  • No change-detector tests added (per repo guidance); the constants aren't asserted by literal value anywhere.

Test plan

  • tsc -b clean.
  • Gateway suite: 307 passed (1 pre-existing failure unrelated, confirmed on main).
  • Forward path verified earlier: a contract-2 desktop ↔ contract-2 backend routes new chats + resumes to the correct profile across all 5 topologies (local-single/multi, global-remote, per-profile-remote, mixed).

…urfaced

#39921/#39993 added per-session profile routing to the WS backend
(session.create / session.resume accept `profile`; the backend builds the agent
and persists against that profile's home/state.db). The desktop already sends
`profile`, but a backend on OLD code silently ignores it — new chats land in the
launch profile and "who are you" answers as the wrong profile.

This bites anyone whose backend is a SEPARATE install from the desktop — the
common remote case: update the desktop app, but the remote VM's Hermes is still
old. Both still reported DESKTOP_BACKEND_CONTRACT = 1, so the desktop's existing
skew guard (reportBackendContract → "Backend out of date" toast with one-click
update) never fired. The user just sees silent cross-profile leakage with no clue
why.

Bump the contract on both sides to 2:
- tui_gateway/server.py: DESKTOP_BACKEND_CONTRACT = 2 (with version history note).
- apps/desktop/src/store/updates.ts: REQUIRED_BACKEND_CONTRACT = 2.

Now a profile-routing-aware desktop pointed at a pre-#39921 backend sees the
backend report contract 1 < required 2 → the "Backend out of date" warning fires
instead of silently misrouting sessions. No behavior change when desktop and
backend are updated together (the single-machine case).
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: bb/backend-contract-bump-profile-routing vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9869 on HEAD, 9869 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5117 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

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

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant