Repository navigation
fix(renderer): surface refused background writes and external opens - #1886
Conversation
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.
f35e0f0 to
91ec00c
Compare
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.
|
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. |
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, insideselectSession:The optimistic value is applied to the row before either branch (
applyOptimisticSessionConfiguration), andconfigureSessionis a rawinvokewrapper — 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 globalunhandledrejectionhandler).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:electron/main/ipc/workspace-ipc.tscallsshell.openExternal, which rejects when the platform has no protocol handler or a policy blocks the URL. The click then did nothing at all. The neighbouringpluginViewClosepath 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.mjspins both contracts: neither call may be a barevoid, each must catch and toast, and the active-session branch keeps its existing flush. 2/2 pass.Not included (deliberately)
refreshSessionshas the same "throws to everyvoidcaller" shape, but that is its existing contract (SearchDialogalready 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.