Skip to content

fix(renderer): surface refused background writes and external opens - #1886

Merged
vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/silent-background-failures
Oct 26, 2026
Merged

vastsa merged 4 commits into
vastsa:mainfrom
SeanLiu326:fix/silent-background-failures

Conversation

@SeanLiu326

Copy link
Copy Markdown
Contributor

What

Two fire-and-forget calls in the store slices discarded a rejection whose consequence the user can see. Both now report the failure exactly the way their sibling paths in the same file already do.

1. A background session's model pin was dropped silently

apps/desktop/src/stores/slices/session-slice.ts, inside selectSession:

if (get().activeSessionId === id) {
  void get().configureActiveSession({ ... });   // flushes through a catch that toasts
} else {
  void api.configureSession(id, { ... });      // no catch at all
}

The optimistic value is applied to the row before either branch (applyOptimisticSessionConfiguration), and configureSession is a raw invoke wrapper — its main handler throws when the host is unavailable or refuses the write (electron/main/ipc/session-ipc.ts). So when the write failed, the row kept the new model while the host still held the old one, and the pin silently reverted the next time that session launched. No toast, no retry, unhandled rejection (the renderer has no global unhandledrejection handler).

Now the background branch catches and toasts the same message the active branch reports through flushPendingSessionConfiguration (stores/runtime/session-coordination.ts).

2. A refused external open looked like a no-op

apps/desktop/src/stores/slices/work-panel-slice.ts, openUrlInWorkPanel's fallback when the browser plugin is absent:

void api.browserOpenExternal(url.trim());

electron/main/ipc/workspace-ipc.ts calls shell.openExternal, which rejects when the platform has no protocol handler or a policy blocks the URL. The click then did nothing at all. The neighbouring pluginViewClose path 10 lines above already does .catch((error) => get().showToast(String(error), { variant: "error" })); this now matches it.

Tests

apps/desktop/test/background-write-failures.test.mjs pins both contracts: neither call may be a bare void, each must catch and toast, and the active-session branch keeps its existing flush. 2/2 pass.

Not included (deliberately)

refreshSessions has the same "throws to every void caller" shape, but that is its existing contract (SearchDialog already attaches .catch(() => undefined)) and swallowing it internally would change what awaiting callers can observe — that one is a design question, not a drop-a-failure bug.

Two fire-and-forget calls in the store slices discarded a rejection that
the user can see the consequences of:

- Selecting a session with a pinned model wrote the pin optimistically and
  then dropped the host write for any non-active session. The active
  session's branch flushes through a catch that toasts; this one left the
  row showing the new model while the host kept the old one, so the pin
  silently reverted on the next launch.
- The work panel's fallback for http(s) links called the OS browser with
  no catch, so a platform with no handler (or a policy that blocks the
  URL) made the click look like a no-op. The neighbouring pluginViewClose
  path in the same slice already toasts its rejection.

Both now report the failure the way their sibling paths do.
@SeanLiu326
SeanLiu326 force-pushed the fix/silent-background-failures branch from f35e0f0 to 91ec00c Compare October 26, 2026 01:20
The Electron E2E failed in the long-history probe's reader-scroll assertion ("stream stole the reader's scroll position") on a branch that only adds catch handlers to two store slices. The probe drives 10784-message histories with synthetic scroll events and latency budgets, so a loaded runner can fail it; this retrigger distinguishes that from a real regression.
Second consecutive Electron E2E failure in pnpm test:e2e:provider-client-certificate: the probe hung and was SIGKILLed after 65s with dbus connection errors. The earlier long-history scroll failure did not reproduce, so the probe's own scroll assertion was a flake too.

vastsa commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Independent review confirms both failures on the real renderer store/IPC path: a refused external open and a model-pin write to a session that became inactive each produce an unhandled rejection with no toast on old main. With this patch, both produce the expected error toast and no unhandled rejection. The isolated React/Chromium probe also rechecked disclosure clicks and concurrent capability-row guards; all six behavioral checks pass. The candidate passes 58 background-write/session-model/work-panel tests, Desktop typecheck, and diff checks. Current main has been merged into this PR branch without rewriting the contributor history, and its executable tree matches the locally tested candidate. Root cause and fix are confirmed; proceeding to merge while ignoring CI status as requested.

@vastsa
vastsa merged commit 541471d into vastsa:main Oct 26, 2026
6 checks passed

This branch was previously deployed

1 inactive deployment
Preview — c49747a8 Deployed Oct 26, 2026 by vercel[bot]
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.

2 participants