mirror of
https://github.com/stablyai/orca.git
synced 2026-09-30 08:03:12 +00:00
perf: move repository hooks flush cleanup to root ref (#4173)
This commit is contained in:
@@ -649,6 +649,17 @@ export function RepositoryHooksSection({
|
||||
flushScriptDraft()
|
||||
}, [flushScriptDraft])
|
||||
|
||||
// Why: unmount can happen before textareas blur; the root ref preserves the
|
||||
// pending local-command save without paying for a cleanup-only Effect.
|
||||
const flushScriptDraftOnUnmount = useCallback(
|
||||
(node: HTMLElement | null): void => {
|
||||
if (node === null) {
|
||||
flushScriptDraft()
|
||||
}
|
||||
},
|
||||
[flushScriptDraft]
|
||||
)
|
||||
|
||||
const updateHookSettingsPolicyDraft = useCallback(
|
||||
(updates: HookSettingsPolicyDraft) => {
|
||||
persistHookSettings({ ...hookSettingsDraftRef.current, ...updates })
|
||||
@@ -677,12 +688,6 @@ export function RepositoryHooksSection({
|
||||
setHookSettingsDraft(next)
|
||||
}, [flushScriptDraft, onUpdateHookSettings, repo.id, repo.hookSettings, syncHookSettingsDraft])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
flushScriptDraft()
|
||||
}
|
||||
}, [flushScriptDraft])
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
const repoId = repo.id
|
||||
@@ -772,7 +777,7 @@ export function RepositoryHooksSection({
|
||||
const [isAdvancedOpen, setIsAdvancedOpen] = useState(false)
|
||||
|
||||
return (
|
||||
<section className="space-y-6">
|
||||
<section ref={flushScriptDraftOnUnmount} className="space-y-6">
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-sm font-semibold">Worktree Hooks</h2>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user