Skip to content

bug(desktop): composer flashes "还没有可用的模型连接,无法发送" and blocks send during every connection snapshot refresh #4611

Closed

Description

@me2seeks

Symptom

With a working model connection configured, the composer intermittently shows the no-model banner — 还没有可用的模型连接,无法发送。前往模型设置 — and Send is disabled while it is visible (screenshot 2026-09-03). The banner then disappears on its own. To the user it reads as "sending sometimes randomly claims there is no model".

Root cause

The banner is driven by an empty snapshot used as the loading state:

  1. apps/desktop/src/renderer/app-shell.tsx:3031 — noModelConnection={connections.length === 0}, where connections is useShellConnections(...).snapshot.
  2. apps/desktop/src/renderer/use-shell-connections.ts:158 — snapshot: projection.status === 'ready' ? projection.snapshot : EMPTY_SNAPSHOT (lines 42–46: connections: []).
  3. use-shell-connections.ts:111 — refreshConnections() first replaces the projection with { status: 'refreshing' }, discarding the previously ready snapshot, and only restores 'ready' after the async IPC read resolves.
  4. Refresh triggers are frequent: hook mount / target-key change (useLayoutEffect on snapshotKey), and every connection_list_changed event (app-shell.tsx:621–624 fans one event out to all three connection hooks).

So on every refresh window — mount, session switch, any connection-list event — the composer briefly believes there are zero connections: the banner renders and sendDisabled (packages/ui/src/composer.tsx, sendDisabled includes noModelConnection) blocks the send. The new-task path has a partial mitigation (app-shell.tsx:590–606 falls back to startupConnectionSnapshot when the projection is unrequested), but the active-session path has no such fallback — activeConnectionSnapshot = activeId ? sessionHostConnections.snapshot : newTaskConnectionSnapshot.

Expected

A refresh must not retract knowledge the shell already has. Keep exposing the last ready snapshot while a refresh is in flight (stale-while-revalidate); only an explicit connection_list_changed result that genuinely returns zero connections should show the banner. The unrequested state (first paint before any read) can keep the current empty/loading behavior, ideally as a neutral loading state rather than a "go configure a model" dead-end.

Repro

  1. Open a session with a healthy connection.
  2. Trigger any connection-list change (add/edit/remove a connection in Settings · Models, or switch sessions so the session-host key changes).
  3. Watch the composer: the no-model banner flashes and Send is disabled for the duration of the IPC round-trip.

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions