@devries-cameron20 / t3code-1 / commits / 70f5dfcef7
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Stabilize keybindings toast stream setup (#1860)

Co-authored-by: Julius Marminge <julius@macmini.local>

Julius Marminge committed Apr 9, 2026 at 14:26 UTC 70f5dfcef78a8e153ab698c0b83661974a4fc033
1 file changed +29 -8
apps/web/src/components/KeybindingsToast.browser.tsx
+29 -8
@@ -21,7 +21,7 @@ import { render } from "vitest-browser-react";
21 import { useComposerDraftStore } from "../composerDraftStore";
22 import { __resetLocalApiForTests } from "../localApi";
23 import { AppAtomRegistryProvider } from "../rpc/atomRegistry";
24 -import { getServerConfig } from "../rpc/serverState";
24 +import { getServerConfig, getServerConfigUpdatedNotification } from "../rpc/serverState";
25 import { getWsConnectionStatus } from "../rpc/wsConnectionState";
26 import { getRouter } from "../router";
27 import { useStore } from "../store";
@@ -303,11 +303,6 @@ async function waitForNoToasts(): Promise<void> {
303 );
304 }
305
306 -async function warmServerConfigUpdateStream(): Promise<void> {
307 - sendServerConfigUpdatedPush([]);
308 - await new Promise((resolve) => setTimeout(resolve, 50));
309 -}
310 -
306 async function waitForInitialWsSubscriptions(): Promise<void> {
307 await vi.waitFor(
308 () => {
@@ -331,6 +326,33 @@ async function waitForServerConfigSnapshot(): Promise<void> {
326 );
327 }
328
329 +async function waitForServerConfigStreamReady(): Promise<void> {
330 + const previousNotificationId = getServerConfigUpdatedNotification()?.id ?? 0;
331 + for (let attempt = 0; attempt < 20; attempt += 1) {
332 + rpcHarness.emitStreamValue(WS_METHODS.subscribeServerConfig, {
333 + version: 1,
334 + type: "settingsUpdated",
335 + payload: { settings: fixture.serverConfig.settings },
336 + });
337 +
338 + try {
339 + await vi.waitFor(
340 + () => {
341 + const notification = getServerConfigUpdatedNotification();
342 + expect(notification?.id).toBeGreaterThan(previousNotificationId);
343 + expect(notification?.source).toBe("settingsUpdated");
344 + },
345 + { timeout: 200, interval: 16 },
346 + );
347 + return;
348 + } catch {
349 + await new Promise((resolve) => setTimeout(resolve, 25));
350 + }
351 + }
352 +
353 + throw new Error("Timed out waiting for the server config stream to deliver updates.");
354 +}
355 +
356 async function mountApp(): Promise<{ cleanup: () => Promise<void> }> {
357 const host = document.createElement("div");
358 host.style.position = "fixed";
@@ -356,6 +378,7 @@ async function mountApp(): Promise<{ cleanup: () => Promise<void> }> {
378 await waitForInitialWsSubscriptions();
379 await waitForWsConnection();
380 await waitForServerConfigSnapshot();
381 + await waitForServerConfigStreamReady();
382 await waitForNoToasts();
383
384 return {
@@ -429,8 +452,6 @@ describe("Keybindings update toast", () => {
452 const mounted = await mountApp();
453
454 try {
432 - await warmServerConfigUpdateStream();
433 -
455 sendServerConfigUpdatedPush([]);
456 await waitForToast("Keybindings updated", 1);
457