Skip to content
TypeScript

refactor(web): install draft model reconciliation at app start (#26046)

Julius Marminge6369e284d746
diff --git a/apps/web/src/AppRoot.tsx b/apps/web/src/AppRoot.tsx
index e62b89a40e4..2491e9a813a 100644
--- a/apps/web/src/AppRoot.tsx
+++ b/apps/web/src/AppRoot.tsx
@@ -1,27 +1,12 @@
import { RouterProvider } from "@tanstack/react-router";
-import { useEffect } from "react";
-
-import { subscribeComposerDraftModelReconciliation } from "./composerDraftStore";
-import { environmentThreadShells } from "./state/threads";
-import { environmentShell } from "./state/shell";
import { ElectronBrowserHost } from "./browser/ElectronBrowserHost";
import { QuitHoldOverlay } from "./components/QuitHoldOverlay";
-import { appAtomRegistry, AppAtomRegistryProvider } from "./rpc/atomRegistry";
+import { AppAtomRegistryProvider } from "./rpc/atomRegistry";
import type { AppRouter } from "./router";
// Keep webviews outside the router but inside its atom registry so route changes preserve them.
export function AppRoot({ router }: { readonly router: AppRouter }) {
- useEffect(
- () =>
- subscribeComposerDraftModelReconciliation({
- registry: appAtomRegistry,
- threadShellAtom: environmentThreadShells.threadShellAtom,
- threadRefsAtom: environmentThreadShells.threadRefsAtom,
- shellStateAtom: environmentShell.stateAtom,
- }),
- [],
- );
return (
<AppAtomRegistryProvider>
<RouterProvider router={router} />
diff --git a/apps/web/src/appInit.tsx b/apps/web/src/appInit.tsx
index 0d1855882df..ae7ad7c7df0 100644
--- a/apps/web/src/appInit.tsx
+++ b/apps/web/src/appInit.tsx
@@ -23,7 +23,11 @@ import { startGuideRunNotifications } from "./components/pullRequest/guide/PullR
import { APP_BASE_NAME, APP_DISPLAY_NAME, APP_STAGE_LABEL } from "./branding";
import { resolveServerBackedAppDisplayName } from "./branding.logic";
import { isElectron } from "./env";
-import { subscribeDraftThreadPromotion, useComposerDraftStore } from "./composerDraftStore";
+import {
+ subscribeComposerDraftModelReconciliation,
+ subscribeDraftThreadPromotion,
+ useComposerDraftStore,
+} from "./composerDraftStore";
import { startDefaultThemeAdoption } from "./hooks/useDefaultTheme";
import { startEnvironmentThemeRepaint } from "./hooks/useEnvironmentTheme";
import {
@@ -42,6 +46,7 @@ import { startProviderAuthDelivery } from "./providerAuthDelivery";
import { getRouter, type AppRouter } from "./router";
import { appAtomRegistry } from "./rpc/atomRegistry";
import { primaryServerConfigAtom } from "./state/server";
+import { environmentShell } from "./state/shell";
import { installChatRouteCommands } from "./shortcuts/chatRouteCommands";
import { installCommandPaletteCommands } from "./shortcuts/commandPaletteCommands";
import { registerOpenFavoriteEditorCommand } from "./components/chat/OpenInPickerShortcut";
@@ -179,6 +184,12 @@ export function startAppServices(): AppRouter {
threadShellAtom: environmentThreadShells.quietThreadShellAtom,
threadRefsAtom: environmentThreadShells.threadRefsAtom,
});
+ subscribeComposerDraftModelReconciliation({
+ registry: appAtomRegistry,
+ threadShellAtom: environmentThreadShells.threadShellAtom,
+ threadRefsAtom: environmentThreadShells.threadRefsAtom,
+ shellStateAtom: environmentShell.stateAtom,
+ });
startMainAppLocationTracking(router);
startBackgroundThreadAnnouncements(appAtomRegistry, router);
startThreadVisitedMigration(appAtomRegistry);