A desktop coding agent with free access to frontier models.
TypeScript
fix: editor hunk lock and deleted tabs
ogsamratf89db24f4bb5
diff --git a/apps/app/src/react-app/domains/session/editor/editor-panel.tsx b/apps/app/src/react-app/domains/session/editor/editor-panel.tsxindex 1e68eb04..083161ec 100644--- a/apps/app/src/react-app/domains/session/editor/editor-panel.tsx+++ b/apps/app/src/react-app/domains/session/editor/editor-panel.tsx@@ -496,6 +496,8 @@ export default function EditorPanel(props: EditorPanelProps) {const [navigate, setNavigate] = useState<{ direction: 1 | -1; nonce: number } | null>(null);const [gitBusy, setGitBusy] = useState(false);const [reviewTick, setReviewTick] = useState(0);+ // Bumped after open documents were read again (a file may have been deleted under its tab).+ const [docsTick, setDocsTick] = useState(0);const recentRef = useRef<string[]>([]);// ── data ───────────────────────────────────────────────────────────────@@ -527,7 +529,7 @@ export default function EditorPanel(props: EditorPanelProps) {const wasBusy = useRef(sessionBusy);useEffect(() => {if (wasBusy.current && !sessionBusy) {- void docs.refresh();+ void docs.refresh().then(() => setDocsTick((value) => value + 1));void queryClient.invalidateQueries({ queryKey: ["editor-tree", workspaceId] });void queryClient.invalidateQueries({ queryKey: ["editor-git", workspaceId] });void queryClient.invalidateQueries({ queryKey: ["editor-changes", workspaceId] });@@ -542,7 +544,7 @@ export default function EditorPanel(props: EditorPanelProps) {// At most every 5 s: switching windows quickly must not re-read every open file each time.if (Date.now() - last < 5_000) return;last = Date.now();- void docs.refresh();+ void docs.refresh().then(() => setDocsTick((value) => value + 1));};window.addEventListener("focus", onFocus);return () => window.removeEventListener("focus", onFocus);@@ -781,7 +783,7 @@ export default function EditorPanel(props: EditorPanelProps) {cancelled = true;};// reviewFiles changes identity per fetch; the key carries what matters.- }, [activeTab, docs, client, workspaceId, reviewKey, changesQuery.isFetching]);+ }, [activeTab, docs, client, workspaceId, reviewKey, changesQuery.isFetching, docsTick]);// ── save ───────────────────────────────────────────────────────────────const save = useCallback(async (options: { force?: boolean } = {}) => {diff --git a/apps/app/src/react-app/domains/session/editor/editor-surface.tsx b/apps/app/src/react-app/domains/session/editor/editor-surface.tsxindex 14f5986d..1ef325ff 100644--- a/apps/app/src/react-app/domains/session/editor/editor-surface.tsx+++ b/apps/app/src/react-app/domains/session/editor/editor-surface.tsx@@ -218,8 +218,9 @@ export function EditorSurface({ monaco, surface, onSave, onCursor, onHunks, naviconst review = surface.review? { onAccept: decide(surface.review.onAccept), onReject: decide(surface.review.onReject) }: null;- const render = () => {- setLocked(false);+ const render = (fromDiff: boolean) => {+ // Only a recomputed diff makes the bars' line numbers current again.+ if (fromDiff) setLocked(false);const changes = (diff.getLineChanges() ?? []).map((change) => ({originalStartLineNumber: change.originalStartLineNumber,originalEndLineNumber: change.originalEndLineNumber,@@ -252,6 +253,7 @@ export function EditorSurface({ monaco, surface, onSave, onCursor, onHunks, navigetDomNode: () => bar,getPosition: () => null,};+ if (locked) bar.classList.add("omnirush-hunk-bar-busy");modifiedEditor.addOverlayWidget(widget);overlays.current.push(widget);const spacer = document.createElement("div");@@ -271,13 +273,13 @@ export function EditorSurface({ monaco, surface, onSave, onCursor, onHunks, navi});});};- const subscription = diff.onDidUpdateDiff(render);+ const subscription = diff.onDidUpdateDiff(() => render(true));// A bar whose zone scrolled out of view is hidden until the zone is drawn again.const scroll = modifiedEditor.onDidScrollChange(() => {for (const widget of overlays.current) widget.getDomNode().style.visibility = "hidden";});- const layout = modifiedEditor.onDidLayoutChange(() => render());- render();+ const layout = modifiedEditor.onDidLayoutChange(() => render(false));+ render(true);return () => {if (unlockTimer) clearTimeout(unlockTimer);subscription.dispose();