fix(editor): close post-commit ref window

This commit is contained in:
Neil
2026-08-10 12:06:15 -07:00
parent b01248cc80
commit c6827c4a45
2 changed files with 4 additions and 4 deletions
@@ -1,7 +1,7 @@
/* oxlint-disable max-lines -- Why: content loading, retry, and external-change
subscriptions share in-flight caches and state setters; splitting them would
make the hook coordination harder to audit. */
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import type { OpenFile } from '@/store/slices/editor'
import { getConnectionIdForFile, isWorktreeConnectionResolved } from '@/lib/connection-context'
import { joinPath } from '@/lib/path'
@@ -133,7 +133,7 @@ export function useEditorPanelContentState({
const activeContentFileId = selectedConflictReviewFile?.id ?? activeFile?.id ?? null
const activeContentFileIdRef = useRef(activeContentFileId)
useEffect(() => {
useLayoutEffect(() => {
// Why: event-driven readers must only observe state from committed renders.
diffContentsRef.current = diffContents
openFilesRef.current = openFiles
@@ -1,6 +1,6 @@
// @vitest-environment happy-dom
import { act, useEffect, useRef, useState } from 'react'
import { act, useLayoutEffect, useRef, useState } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { OpenFile } from '@/store/slices/editor'
@@ -30,7 +30,7 @@ function ExternalContentProbe({ activeFileId, calls, isVisible, openFiles }: Pro
const [, setFileContents] = useState<Record<string, FileContent>>({})
const [, setDiffContents] = useState<Record<string, DiffContent>>({})
useEffect(() => {
useLayoutEffect(() => {
activeContentFileIdRef.current = activeFileId
isVisibleRef.current = isVisible
openFilesRef.current = openFiles