merge #1057: perf(sidebar): 页签内容的会话 scope 改为按内容稳定,消除无关重渲染导致的整文件重读
This commit is contained in:
commit
01a6fa573b
16 files changed
+300
-39
No files matched your search
@@ -152,8 +152,7 @@ export function ChangesTab({ ctx, store, scope, tab, visible, onOpenFile, onOpen
|
||||
} finally {
|
||||
if (generation === pollGen.current) pullingRef.current = false
|
||||
}
|
||||
// Granular scope fields: the scope object's identity churns, only its
|
||||
// sessionId / cwd fields gate the poll target.
|
||||
// Granular scope fields: only these two gate the poll target.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [scope.sessionId, scope.cwd])
|
||||
useEffect(() => {
|
||||
|
||||
@@ -308,6 +308,11 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose,
|
||||
const [gitContent, setGitContent] = useState<
|
||||
{ status: 'idle' | 'loading' | 'binary' | 'large' } | { status: 'text'; text: string } | { status: 'error'; error: string }
|
||||
>({ status: 'idle' })
|
||||
// The pane owns the refresh GESTURE: the header button bumps this, and both
|
||||
// loaders reload on it. The scope is stable, so a plain re-render no longer
|
||||
// re-reads the file as a side effect — without this the content tab would
|
||||
// keep bytes read before the file changed, and it has no other reload path.
|
||||
const [refreshSeq, setRefreshSeq] = useState(0)
|
||||
useEffect(() => {
|
||||
if (gitWorktree === null) { setGitContent({ status: 'idle' }); return }
|
||||
// Deferred until the content view is the one on screen: opening a file to
|
||||
@@ -327,7 +332,7 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose,
|
||||
setGitContent({ status: 'error', error: reason instanceof Error ? reason.message : String(reason) })
|
||||
})
|
||||
return () => { controller.abort() }
|
||||
}, [gitWorktree, scope, active])
|
||||
}, [gitWorktree, scope, active, refreshSeq])
|
||||
|
||||
// ── Op target material (pure snapshots; the prior content came with the
|
||||
// target so a running op shows what is already known). ────────────────
|
||||
@@ -589,7 +594,12 @@ export function DiffPane({ target, ctx, scope, height, onHeightCommit, onClose,
|
||||
icon={<IconRefreshOutlineRegular size={14} />}
|
||||
label={t('refresh')}
|
||||
disabled={loading}
|
||||
onClick={refresh}
|
||||
onClick={() => {
|
||||
// Both views reload: the patch (refresh) and the whole-file
|
||||
// content tab, which read its bytes through its own fs.read.
|
||||
refresh()
|
||||
setRefreshSeq(sequence => sequence + 1)
|
||||
}}
|
||||
/>
|
||||
<IconButton
|
||||
size="sm"
|
||||
|
||||
Reference in new issue
Block a user