Skip to content

Commit 000b4fb

Browse files
nedtwiggclaude
andcommitted
Delay auto-spawn so kill/detach animation can finish first
On last-pane kill/detach, the outgoing-pane animation (crush or detach-to-door) and the incoming-pane reveal used to start at the same time and fight for the same screen region. Now the spawn is deferred by 440ms (the animation duration) so the two play sequentially. If any other action re-populates the pane area during the delay (e.g. door reattach), the deferred spawn becomes a no-op. Reduced-motion skips the delay. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e665bf4 commit 000b4fb

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/src/components/Pond.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,14 +1474,26 @@ export function Pond({
14741474
// or detached), spawn a fresh one — regardless of whether doors exist. Carry
14751475
// the just-removed pane's id forward as paneToCopy so future work can copy
14761476
// cwd / terminal kind from it.
1477+
//
1478+
// Delay the spawn by the kill/detach animation duration so the two animations
1479+
// don't overlap — the outgoing pane crushes/fades first, then the new pane
1480+
// reveals from the top-left. If anything restores a pane in the meantime
1481+
// (e.g. door reattach), the delayed spawn becomes a no-op.
14771482
e.api.onDidRemovePanel((removed) => {
1478-
if (e.api.totalPanels === 0) {
1483+
if (e.api.totalPanels !== 0) return;
1484+
const reduceMotion = typeof window !== 'undefined'
1485+
&& window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
1486+
const delay = reduceMotion ? 0 : 440;
1487+
const spawn = () => {
1488+
if (e.api.totalPanels > 0) return;
14791489
const id = generatePaneId();
14801490
paneToCopyByIdRef.current.set(id, removed.id);
14811491
freshlySpawnedRef.current.set(id, 'top-left');
14821492
e.api.addPanel({ id, component: 'terminal', tabComponent: 'terminal', title: '<unnamed>' });
14831493
selectPanel(id);
1484-
}
1494+
};
1495+
if (delay === 0) spawn();
1496+
else setTimeout(spawn, delay);
14851497
});
14861498

14871499
onApiReady?.(e.api);

0 commit comments

Comments
 (0)