TypeScript
chore(lint): enforce react/set-state-in-effect (#25119)
Julius Marminge7f26969c510e
diff --git a/apps/mobile/src/components/MediaVideoPlayer.tsx b/apps/mobile/src/components/MediaVideoPlayer.tsxindex 2c4d70e1aa9..89b3aed219a 100644--- a/apps/mobile/src/components/MediaVideoPlayer.tsx+++ b/apps/mobile/src/components/MediaVideoPlayer.tsx@@ -91,6 +91,7 @@ function LoadedMediaVideo(props: {useEffect(() => {const controller = new AbortController();+ // oxlint-disable-next-line react/set-state-in-effect -- Starting a native media load publishes pending before its async result.setLoadState("pending");// A renewed signature is used on Retry, not as a reason to reset the native player.void loadSource(controller.signal).then(diff --git a/apps/mobile/src/components/ProjectFavicon.tsx b/apps/mobile/src/components/ProjectFavicon.tsxindex ab43945dd73..3e0f0974126 100644--- a/apps/mobile/src/components/ProjectFavicon.tsx+++ b/apps/mobile/src/components/ProjectFavicon.tsx@@ -168,6 +168,7 @@ function ProjectFaviconImage(props: {if (faviconRequest === null) return;const endRequest = beginProjectFaviconRequest(faviconRequest);+ // oxlint-disable-next-line react/set-state-in-effect -- Publishes the favicon request registered with the external loader until its cleanup runs.setActiveFaviconRequest(faviconRequest);return endRequest;}, [faviconRequest]);diff --git a/apps/mobile/src/components/VideoPreviewModal.ios.tsx b/apps/mobile/src/components/VideoPreviewModal.ios.tsxindex eede25a97f0..0eec525abba 100644--- a/apps/mobile/src/components/VideoPreviewModal.ios.tsx+++ b/apps/mobile/src/components/VideoPreviewModal.ios.tsx@@ -70,6 +70,7 @@ function NativeVideoPreview(props: {return () => fullscreenVideoClosed();}, []);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- The native player latches the first resolved URL to keep its playback session.if (playbackUrl === null && resolvedUrl !== null) setPlaybackUrl(resolvedUrl);}, [playbackUrl, resolvedUrl]);useEffect(() => {diff --git a/apps/mobile/src/components/VideoPreviewModal.tsx b/apps/mobile/src/components/VideoPreviewModal.tsxindex 697577742ce..9b2b64c68c4 100644--- a/apps/mobile/src/components/VideoPreviewModal.tsx+++ b/apps/mobile/src/components/VideoPreviewModal.tsx@@ -64,6 +64,7 @@ function useLocalPlayback(source: LocalVideoPreviewSource): PlaybackState {);const { id: attachmentId, fileUri } = attachment;useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- A new attachment clears the previous attachment's result before loading.setUri(null);setError(null);const controller = new AbortController();diff --git a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsxindex c9048d6f06e..2ea5efc780d 100644--- a/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx+++ b/apps/mobile/src/features/connection/ConnectionsNewRouteScreen.tsx@@ -77,6 +77,7 @@ export function ConnectionsNewRouteScreen({useEffect(() => {const { host, code } = parsePairingUrl(connectionPairingUrl);+ // oxlint-disable-next-line react/set-state-in-effect -- A new pairing URL reseeds the editable host and code fields.setHostInput(host);setCodeInput(code);}, [connectionPairingUrl]);@@ -87,12 +88,14 @@ export function ConnectionsNewRouteScreen({}const { host, code } = parsePairingUrl(routePairingUrl);+ // oxlint-disable-next-line react/set-state-in-effect -- A pairing URL from the route reseeds the editable host and code fields.setHostInput(host);setCodeInput(code);}, [routePairingUrl]);useEffect(() => {if (pairingConnectionError) {+ // oxlint-disable-next-line react/set-state-in-effect -- A pairing failure reported by the connection runtime ends the submit.setIsSubmitting(false);}}, [pairingConnectionError]);diff --git a/apps/mobile/src/features/files/FileTreeBrowser.tsx b/apps/mobile/src/features/files/FileTreeBrowser.tsxindex bc38fde7946..c08f21ad498 100644--- a/apps/mobile/src/features/files/FileTreeBrowser.tsx+++ b/apps/mobile/src/features/files/FileTreeBrowser.tsx@@ -153,6 +153,7 @@ export function FileTreeBrowser(props: {if (!controlledSelectedPath) {return;}+ // oxlint-disable-next-line react/set-state-in-effect -- An externally selected file expands its ancestor folders; the user can collapse them afterwards.setExpandedPaths((current) => {const ancestors = ancestorPaths(controlledSelectedPath);if (ancestors.every((ancestor) => current.has(ancestor))) {diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsxindex e29d3f02928..9c7f5ead34f 100644--- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx+++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx@@ -387,6 +387,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestPif (!guidesEnabled && section === "guide") {requestedSection.current = "overview";currentScrollOffset.current = scrollOffsets.current.overview ?? -insets.top;+ // oxlint-disable-next-line react/set-state-in-effect -- When guides turn off, the tab and its saved scroll offset must switch to overview together.setSection("overview");}}, [guidesEnabled, section, insets.top, currentScrollOffset, requestedSection, scrollOffsets]);diff --git a/apps/mobile/src/features/review/useNativeReviewDiffHighlighting.ts b/apps/mobile/src/features/review/useNativeReviewDiffHighlighting.tsindex 652b03682b1..b398867ea2d 100644--- a/apps/mobile/src/features/review/useNativeReviewDiffHighlighting.ts+++ b/apps/mobile/src/features/review/useNativeReviewDiffHighlighting.ts@@ -59,6 +59,7 @@ export function useNativeReviewDiffHighlighting(input: {const previousRange = scheduler.reset();highlightedRowIdsRef.current = new Set();pendingPatchesRef.current = [];+ // oxlint-disable-next-line react/set-state-in-effect -- Resetting the native highlighter clears the viewport and token-patch snapshots together.setViewport({ scope: viewportScope, range: null });setTokensPatchJson(createEmptyTokenPatch(resetKey));// A token reset need not produce another native range event. Reuse only andiff --git a/apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsxindex 6959e1e74db..701403f3a4b 100644--- a/apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx+++ b/apps/mobile/src/features/settings/SettingsNotificationsRouteScreen.tsx@@ -116,6 +116,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {};useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Reads native notification permission on mount and on every foreground.void refreshNotifications();const subscription = AppState.addEventListener("change", (state) => {if (state === "active") void refreshNotifications();@@ -125,6 +126,7 @@ function ConfiguredSettingsNotificationsRouteScreen() {useEffect(() => {if (!isLoaded) {+ // oxlint-disable-next-line react/set-state-in-effect -- Live Activity status shows checking until stored preferences load.setLiveActivityStatus("checking");return;}diff --git a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsxindex cfe9021224f..d49fc5f55ee 100644--- a/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx+++ b/apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx@@ -121,6 +121,7 @@ function EnabledShowcaseCaptureCoordinator(props: { readonly pathname: string })if (orientationSettled) return;const orientation = getNativeShowcaseOrientation();if (orientation === null) {+ // oxlint-disable-next-line react/set-state-in-effect -- Capture readiness follows the native orientation change.setOrientationSettled(true);return;}@@ -295,6 +296,7 @@ function EnabledShowcaseCaptureCoordinator(props: { readonly pathname: string })(scene === "agent-activity" && !agentActivityStaged) ||!isShowcaseNativeContentReady({ scene, themeId, renderSignal })) {+ // oxlint-disable-next-line react/set-state-in-effect -- Capture readiness clears while the scene, fixture, or native content is not ready.setReadyScene(null);return;}diff --git a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsxindex 009d2b7d77e..059f6ff2b12 100644--- a/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx+++ b/apps/mobile/src/features/threads/NewTaskDraftRouteScreen.tsx@@ -37,6 +37,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDrafconst [initialized, setInitialized] = useState(false);useLayoutEffect(() => {reset();+ // oxlint-disable-next-line react/set-state-in-effect -- Draft reset runs once before first paint; initialized gates the screen until then.setInitialized(true);}, [reset]);const pendingTaskId = Array.isArray(params.pendingTaskId)@@ -90,6 +91,7 @@ export function NewTaskDraftRouteScreen({ route }: StaticScreenProps<NewTaskDrafif (!needsPreparation || !initialProjectRef.branch || waitingForProject) return;const branchName = initialProjectRef.branch;let active = true;+ // oxlint-disable-next-line react/set-state-in-effect -- Counts the serialized Git checkout this effect starts.setPendingCheckouts((count) => count + 1);// Serialize replacements: ignoring a stale result cannot undo its Git mutation.checkoutTail.current = checkoutTail.current.then(async () => {diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsxindex f9b312e40e0..a9f6d5db7c5 100644--- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx+++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx@@ -355,6 +355,7 @@ export function NewTaskDraftScreen(props: {return;}if (requestedInitialProjectAvailable) {+ // oxlint-disable-next-line react/set-state-in-effect -- Ends the return-to-picker flow once the requested project arrives from the catalog.setIsReturningToProjectPicker(false);return;}@@ -493,6 +494,7 @@ export function NewTaskDraftScreen(props: {}if (projects.length > 0) {+ // oxlint-disable-next-line react/set-state-in-effect -- Route-driven project resolution starts the return-to-picker flow when no project matches.setIsReturningToProjectPicker(true);}return;@@ -595,6 +597,7 @@ export function NewTaskDraftScreen(props: {let didConsumeShare = false;let needsDraftRestore = false;activeShareImportTokenRef.current = importToken;+ // oxlint-disable-next-line react/set-state-in-effect -- Publishes the share import started by this effect before its async work runs.setImportingShareKey(importKey);void (async () => {await reserveShare(shareId, {diff --git a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsxindex 72e80022a46..ff8865e166b 100644--- a/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx+++ b/apps/mobile/src/features/threads/ThreadArrangementSheet.tsx@@ -288,7 +288,7 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) {.map((row) => `${row.key}:${row.thread?.pinOrderKey}:${row.thread?.activeOrderKey}`).join("|");useEffect(() => {- // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A changed thread order cancels the in-progress drag; stop only touches refs and state setters.+ // oxlint-disable-next-line react/exhaustive-effect-dependencies, react/set-state-in-effect -- A changed thread order cancels the in-progress drag and clears its preview; stop only touches refs and state setters.stop();}, [orderVersion]);useEffect(diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsxindex 85732afaa17..77351fbd23c 100644--- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx+++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx@@ -421,6 +421,7 @@ function ThreadDetailBody(props: ThreadDetailScreenProps) {};}, []);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Any native keyboard report clears the suspect flag set when the app resumed.setKeyboardStateSuspect(false);// oxlint-disable-next-line react/exhaustive-effect-dependencies -- Any keyboard visibility or height report clears the suspect flag set when the app resumed.}, [isKeyboardVisible, liveKeyboardHeight]);diff --git a/apps/mobile/src/features/threads/ThreadMarkdownImage.test.tsx b/apps/mobile/src/features/threads/ThreadMarkdownImage.test.tsxnew file mode 100644index 00000000000..88ebb7109c9--- /dev/null+++ b/apps/mobile/src/features/threads/ThreadMarkdownImage.test.tsx@@ -0,0 +1,66 @@+import type { ReactNode } from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { expect, it, vi } from "vite-plus/test";++const harness = vi.hoisted(() => ({+ failImage: () => {},+ Passthrough: ({ children }: { children?: unknown }) => children,+}));++vi.mock("react-native", () => ({+ Pressable: harness.Passthrough,+ StyleSheet: { absoluteFill: {} },+ View: harness.Passthrough,+}));+vi.mock("expo-image", () => ({+ Image: (props: { onError: () => void }) => {+ harness.failImage = props.onError;+ return <img alt="" />;+ },+}));+vi.mock("expo/fetch", () => ({ fetch: vi.fn() }));+vi.mock("react-native-svg", () => ({ parse: vi.fn(), SvgAst: () => null }));+vi.mock("@t3tools/client-runtime/state/assets", () => ({ MISSING_FILE_ACCESS_MESSAGE: "" }));+vi.mock("../../components/ui/AppActivityIndicator", () => ({ AppActivityIndicator: () => null }));+vi.mock("../../components/FilePreviewGallery", () => ({+ useFilePreviewGallery: () => (source: unknown) => source,+}));+vi.mock("../../components/ui/AppText", () => ({+ AppText: ({ children }: { children?: ReactNode }) => <span>{children}</span>,+}));+vi.mock("../../components/MediaActionsMenu", () => ({ MediaActionsMenu: harness.Passthrough }));+vi.mock("../../components/ui/NativePresentation", () => ({+ PresentationSource: harness.Passthrough,+}));+vi.mock("../../state/mediaActions", () => ({ useMediaActions: () => ({ actions: [] }) }));+vi.mock("../../state/assets", () => ({ useAssetUrlState: vi.fn() }));++import { ThreadMarkdownImageView } from "./ThreadMarkdownImage";++it("retries a failed image once its URI comes back through null", async () => {+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;+ const container = document.createElement("div");+ const root = createRoot(container);+ const view = (uri: string | null) => (+ <ThreadMarkdownImageView+ uri={uri}+ sourceKey="attachment:a"+ unavailable={false}+ alt={null}+ onPressPreview={() => {}}+ />+ );+ try {+ await act(async () => root.render(view("https://example.test/a.png")));+ await act(async () => harness.failImage());+ expect(container.textContent).toContain("Image unavailable");++ await act(async () => root.render(view(null)));+ await act(async () => root.render(view("https://example.test/a.png")));+ expect(container.textContent).not.toContain("Image unavailable");+ expect(container.querySelector("img")).not.toBeNull();+ } finally {+ await act(async () => root.unmount());+ }+});diff --git a/apps/mobile/src/features/threads/ThreadMarkdownImage.tsx b/apps/mobile/src/features/threads/ThreadMarkdownImage.tsxindex 8bf66c87a46..9b6075615aa 100644--- a/apps/mobile/src/features/threads/ThreadMarkdownImage.tsx+++ b/apps/mobile/src/features/threads/ThreadMarkdownImage.tsx@@ -45,18 +45,15 @@ export function ThreadMarkdownImageView(props: {measuredWidth > 0 && contextWidth > 0? Math.min(contextWidth, measuredWidth): contextWidth || measuredWidth;- const [decodedSize, setDecodedSize] = useState<{ width: number; height: number } | null>(null);- const [failedUri, setFailedUri] = useState<string | null>(null);-- useEffect(() => {- setDecodedSize(null);- // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A new source invalidates the decoded image dimensions.- }, [props.sourceKey]);-- useEffect(() => {- setFailedUri(null);- // oxlint-disable-next-line react/exhaustive-effect-dependencies -- A new image URI clears the previous load failure.- }, [props.uri]);+ // Keyed by source so a new source drops the previous image's decoded dimensions.+ const [decoded, setDecoded] = useState<{+ sourceKey: string;+ size: { width: number; height: number };+ } | null>(null);+ const decodedSize = decoded?.sourceKey === props.sourceKey ? decoded.size : null;+ // A failure belongs to one URI; any URI change, including through null, retries.+ const [failure, setFailure] = useState({ uri: props.uri, failed: false });+ if (failure.uri !== props.uri) setFailure({ uri: props.uri, failed: false });const sourceSize = decodedSize ?? props.knownSize ?? null;const displaySize: MarkdownImageDisplaySize | null =@@ -67,7 +64,8 @@ export function ThreadMarkdownImageView(props: {sourceHeight: sourceSize.height,availableWidth,});- const failed = props.unavailable || (props.uri !== null && failedUri === props.uri);+ const failed =+ props.unavailable || (props.uri !== null && failure.uri === props.uri && failure.failed);const placeholderWidth: ViewStyle["width"] =availableWidth > 0 ? Math.min(availableWidth, MARKDOWN_IMAGE_MAX_WIDTH) : "100%";const frameStyle: ViewStyle = displaySize ?? { width: placeholderWidth, aspectRatio: 16 / 9 };@@ -129,8 +127,8 @@ export function ThreadMarkdownImageView(props: {key={props.sourceKey}uri={props.uri}format={props.format}- onLoad={setDecodedSize}- onError={() => setFailedUri(props.uri)}+ onLoad={(size) => setDecoded({ sourceKey: props.sourceKey, size })}+ onError={() => setFailure({ uri: props.uri, failed: true })}/></View></Pressable>diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsxindex d684076de8c..d5a38188a7a 100644--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx@@ -274,6 +274,7 @@ function ThreadNavigationSidebarPane(const nowMinute = now.slice(0, 16);const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Refreshes the minute clock when the minute interval starts.setNow(new Date().toISOString());const id = setInterval(() => setNow(new Date().toISOString()), 60_000);return () => clearInterval(id);diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsxindex fc949f83f7d..43a1462a655 100644--- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx+++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx@@ -431,6 +431,7 @@ function ThreadRouteContent(]);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Inspector selection follows route ownership but keeps an inspector the user opened.setInspectorSelection((current) => {if (props.renderInspector === undefined) {if (current === null || current.mode === "route") {diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsxindex e961f9e4dfa..43017bfc747 100644--- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx+++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx@@ -418,6 +418,7 @@ export function NewTaskFlowProvider() {return;}+ // oxlint-disable-next-line react/set-state-in-effect -- Creates the persistent draft once the project selection is ready; the key must exist before the composer mounts.setActiveDraftKey(createNewTaskDraft({environmentId: selectedProject.environmentId,diff --git a/apps/mobile/src/features/threads/thread-inspector-content-stack.tsx b/apps/mobile/src/features/threads/thread-inspector-content-stack.tsxindex 9043a1f918b..1dafb439f2d 100644--- a/apps/mobile/src/features/threads/thread-inspector-content-stack.tsx+++ b/apps/mobile/src/features/threads/thread-inspector-content-stack.tsx@@ -58,6 +58,7 @@ export function ThreadInspectorContentStack(props: {);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Keeps opened inspector views mounted so UIKit keeps their focus and scroll.setMountedModes((current) => {if (current.has(props.mode)) {return current;diff --git a/apps/mobile/src/features/threads/use-composer-command-menu.ts b/apps/mobile/src/features/threads/use-composer-command-menu.tsindex 1615f9bd98b..a1d3c42c7fc 100644--- a/apps/mobile/src/features/threads/use-composer-command-menu.ts+++ b/apps/mobile/src/features/threads/use-composer-command-menu.ts@@ -220,6 +220,7 @@ export function useComposerCommandMenu({useEffect(() => {const inserted = ownerKey ? readComposerDraftSelection(ownerKey, draftMessage) : null;if (inserted) {+ // oxlint-disable-next-line react/set-state-in-effect -- Applies a selection inserted into the draft store by another surface.setSelection((current) =>current.start === inserted.start && current.end === inserted.end ? current : inserted,);@@ -301,6 +302,7 @@ export function useComposerCommandMenu({)return;if (hasCurrentProviderWorkspaceSnapshot(selectedProviderStatus, projectCwd, now)) {+ // oxlint-disable-next-line react/set-state-in-effect -- A current provider workspace snapshot clears the pending refresh retry.setWorkspaceRefreshRetry(null);return;}diff --git a/apps/mobile/src/features/threads/use-worktree-setup.ts b/apps/mobile/src/features/threads/use-worktree-setup.tsindex 0dd8d0f7028..cc1c1af091c 100644--- a/apps/mobile/src/features/threads/use-worktree-setup.ts+++ b/apps/mobile/src/features/threads/use-worktree-setup.ts@@ -27,6 +27,7 @@ export function useWorktreeSetup(input: {);const snapshot = resolveWorktreeSetupSnapshot(input.threadId, query.data, live);useEffect(() => {+ // oxlint-disable-next-line react/set-state-in-effect -- Holds the last setup snapshot while the live subscription changes over.if (snapshot && snapshot !== live) setHeld({ key, snapshot });}, [key, live, snapshot]);return {diff --git a/apps/mobile/src/state/use-vcs-action-state.ts b/apps/mobile/src/state/use-vcs-action-state.tsindex a3929b1f3cb..dadc7b3e3ad 100644--- a/apps/mobile/src/state/use-vcs-action-state.ts+++ b/apps/mobile/src/state/use-vcs-action-state.ts@@ -1,7 +1,8 @@import { useAtomValue } from "@effect/atom-react";+import { secondTick } from "@t3tools/client-runtime/clock";import { type VcsActionState, type VcsActionTarget } from "@t3tools/client-runtime/state/vcs";import { Atom } from "effect/reactivity";-import { useEffect, useState } from "react";+import { useSyncExternalStore } from "react";import { appAtomRegistry } from "./atom-registry";import { vcsActionManager } from "./vcs";@@ -61,6 +62,8 @@ export interface GitActionProgress {readonly prUrl?: string;}+const subscribeNever = () => () => {};+const EMPTY_PROGRESS: GitActionProgress = {phase: "idle",label: null,@@ -78,14 +81,11 @@ export function useGitActionProgress(target: VcsActionTarget): GitActionProgressconst actionState = useVcsActionState(target);const { result } = useGitActionResultNotification();- // Keep clock state; the compiler caches render-time Date.now() and would freeze the label.- const [nowMs, setNowMs] = useState(() => Date.now());- useEffect(() => {- if (!actionState.isRunning) return;- setNowMs(Date.now());- const interval = setInterval(() => setNowMs(Date.now()), 1000);- return () => clearInterval(interval);- }, [actionState.isRunning]);+ // Only a running action shows elapsed time, so only it subscribes to the second tick.+ const nowMs = useSyncExternalStore(+ actionState.isRunning ? secondTick.subscribe : subscribeNever,+ secondTick.getSnapshot,+ );if (actionState.isRunning) {const description =diff --git a/apps/mobile/vite.config.ts b/apps/mobile/vite.config.tsindex 77fffb6cb61..d8626617816 100644--- a/apps/mobile/vite.config.ts+++ b/apps/mobile/vite.config.ts@@ -10,6 +10,7 @@ const reactTests = ["src/components/ui/Dialog.android.test.tsx","src/features/settings/SettingsServerControlsRouteScreen.test.tsx","src/features/settings/components/BranchNamingSettings.test.tsx",+ "src/features/threads/ThreadMarkdownImage.test.tsx","src/features/threads/UsageLimitRecoveryCard.test.tsx","src/native/NativeHeaderToolbar.test.tsx","src/native/useRestingTopOffset.test.tsx",diff --git a/vite.config.ts b/vite.config.tsindex 7ab571fb636..8f1936a249a 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -230,6 +230,7 @@ export default defineConfig({"react/purity": "error","react/refs": "error","react/exhaustive-effect-dependencies": "error",+ "react/set-state-in-effect": "error","react/immutability": "error","react/no-array-index-key": "error","react/no-unstable-nested-components": "error",