Skip to content

Commit bde42c8

Browse files
feat: improved cli artifacting when closing panes
1 parent 31356fa commit bde42c8

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

src/DmuxApp.tsx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,40 @@ const DmuxApp: React.FC<DmuxAppProps> = ({ dmuxDir, panesFile, projectName, sess
280280

281281
const closePane = async (pane: DmuxPane) => {
282282
try {
283+
// Multiple clearing strategies to prevent artifacts
284+
// 1. Clear screen with ANSI codes
285+
process.stdout.write('\x1b[2J\x1b[H');
286+
287+
// 2. Fill with blank lines to push content off screen
288+
process.stdout.write('\n'.repeat(100));
289+
290+
// 3. Clear tmux history and send clear command
291+
try {
292+
execSync('tmux clear-history', { stdio: 'pipe' });
293+
execSync('tmux send-keys C-l', { stdio: 'pipe' });
294+
} catch {}
295+
296+
// 4. Force tmux to refresh the display
297+
try {
298+
execSync('tmux refresh-client', { stdio: 'pipe' });
299+
} catch {}
300+
301+
// Small delay to let clearing complete
302+
await new Promise(resolve => setTimeout(resolve, 100));
303+
283304
// Kill the tmux pane
284305
execSync(`tmux kill-pane -t '${pane.paneId}'`, { stdio: 'pipe' });
285306

307+
// Get current pane count to determine layout
308+
const paneCount = parseInt(
309+
execSync('tmux list-panes | wc -l', { encoding: 'utf-8' }).trim()
310+
);
311+
312+
// Apply smart layout after pane removal
313+
if (paneCount > 1) {
314+
applySmartLayout(paneCount);
315+
}
316+
286317
// Remove from list
287318
const updatedPanes = panes.filter(p => p.id !== pane.id);
288319
await savePanes(updatedPanes);
@@ -342,7 +373,7 @@ const DmuxApp: React.FC<DmuxAppProps> = ({ dmuxDir, panesFile, projectName, sess
342373
// Delete branch
343374
execSync(`git branch -d ${pane.slug}`, { stdio: 'pipe' });
344375

345-
// Close the pane
376+
// Close the pane (includes clearing)
346377
await closePane(pane);
347378

348379
setStatusMessage(`Merged ${pane.slug} into ${mainBranch} and closed pane`);
@@ -355,7 +386,7 @@ const DmuxApp: React.FC<DmuxAppProps> = ({ dmuxDir, panesFile, projectName, sess
355386

356387
const deleteUnsavedChanges = async (pane: DmuxPane) => {
357388
if (!pane.worktreePath) {
358-
// No worktree, just close the pane
389+
// No worktree, just close the pane (includes clearing)
359390
await closePane(pane);
360391
return;
361392
}
@@ -373,7 +404,7 @@ const DmuxApp: React.FC<DmuxAppProps> = ({ dmuxDir, panesFile, projectName, sess
373404
// Branch might not exist or have commits, that's ok
374405
}
375406

376-
// Close the pane
407+
// Close the pane (includes clearing)
377408
await closePane(pane);
378409

379410
setStatusMessage(`Deleted worktree ${pane.slug} and closed pane`);

0 commit comments

Comments
 (0)