Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
689a8bd
Add interactive TUI mode with file tree side panel
armanarutiunov Feb 11, 2026
4d11f97
Add per-file addition/deletion line counts
armanarutiunov Feb 11, 2026
c434705
Add dir, border-focused, additions, deletions theme colors
armanarutiunov Feb 11, 2026
0575e48
Rewrite file tree as nested expandable tree with file icons and +N -M…
armanarutiunov Feb 11, 2026
92ae324
Add focus border indicator, ctrl+d/u half-page scroll, update sync fo…
armanarutiunov Feb 11, 2026
53d1685
Match folder color to file name header, darken tree background
armanarutiunov Feb 11, 2026
e5aed4e
Add git staging status detection with green/orange file coloring
armanarutiunov Feb 11, 2026
2cc4e2a
Add staged/partial-staged/file-selected theme colors, fix span ordering
armanarutiunov Feb 11, 2026
4096f5d
Use background-only selection for files, keep inverse for dirs
armanarutiunov Feb 11, 2026
c06368d
Fix dead ternary in FileTreePanel, use execFileSync in gitStatus
armanarutiunov Feb 12, 2026
9a533ca
Deduplicate side-by-side diff parser into single iterSideBySideDiffEv…
armanarutiunov Feb 12, 2026
6eb9fa7
Add Windows fallback for interactive mode, deduplicate TREE_WIDTH/BOR…
armanarutiunov Feb 12, 2026
df4fa57
Fix stale rendering artifacts with ERASE_TO_EOL and screen clear
armanarutiunov Feb 12, 2026
4086e02
Add 'e' key tree toggle and dynamic diff re-render on terminal resize
armanarutiunov Feb 12, 2026
a608033
Fix ttyFd leak, remove dead params, restore comments, export helpers
armanarutiunov Feb 12, 2026
211ffe4
Add unit tests for TUI helpers
armanarutiunov Feb 12, 2026
0be5f85
Make tree width configurable via split-diffs.tree-width
armanarutiunov Feb 12, 2026
6f29eee
Add 'f' key to toggle flat/folder file tree mode
armanarutiunov Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add 'f' key to toggle flat/folder file tree mode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
armanarutiunov and claude committed Mar 12, 2026
commit 6f29eeee8849462adb2265aa23d7516c9bbb20ec
41 changes: 40 additions & 1 deletion src/tui/FileTreePanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,26 @@ export function flattenVisible(nodes: TreeNode[]): VisibleNode[] {
return result;
}

export function flattenFlat(files: DiffFile[]): VisibleNode[] {
return files.map((file, i) => ({
type: 'file' as const,
node: {
type: 'file' as const,
name: file.fileNameB || file.fileNameA || file.displayName,
path: file.fileNameB || file.fileNameA || file.displayName,
file,
fileIndex: i,
depth: 0,
},
fileIndex: i,
}));
}

export class FileTreePanel {
private files: DiffFile[];
private rootNodes: TreeNode[];
private visibleNodes: VisibleNode[] = [];
private flatMode: boolean = false;
private width: number;
private height: number;
private context: Context;
Expand All @@ -120,7 +136,30 @@ export class FileTreePanel {
}

private regenerateVisible(): void {
this.visibleNodes = flattenVisible(this.rootNodes);
this.visibleNodes = this.flatMode
? flattenFlat(this.files)
: flattenVisible(this.rootNodes);
}

toggleFlatMode(): void {
const selectedFileIndex = this.getSelectedFileIndex();
this.flatMode = !this.flatMode;
this.regenerateVisible();
if (selectedFileIndex != null) {
for (let i = 0; i < this.visibleNodes.length; i++) {
const vn = this.visibleNodes[i];
if (vn.type === 'file' && vn.fileIndex === selectedFileIndex) {
this.selectedIndex = i;
this.ensureVisible();
return;
}
}
}
this.selectedIndex = Math.min(
this.selectedIndex,
Math.max(0, this.visibleNodes.length - 1)
);
this.ensureVisible();
}

resize(width: number, height: number): void {
Expand Down
6 changes: 6 additions & 0 deletions src/tui/TuiApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ export class TuiApp {
return;
}

if (key === 'f') {
this.tree.toggleFlatMode();
this.render();
return;
}

if (key === 'tab') {
if (!this.treeVisible) return;
this.focus = this.focus === 'tree' ? 'diff' : 'tree';
Expand Down
39 changes: 38 additions & 1 deletion src/tui/tui.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { truncateAnsi } from './Screen';
import { getFileIcon } from './fileIcons';
import { binarySearchBoundary } from './sync';
import { buildTree, flattenVisible } from './FileTreePanel';
import { buildTree, flattenVisible, flattenFlat } from './FileTreePanel';
import { DiffFile } from './collectDiffData';

const RESET = '\x1b[0m';
Expand Down Expand Up @@ -171,3 +171,40 @@ describe('flattenVisible', () => {
expect(visible[1].node.name).toBe('README.md');
});
});

describe('flattenFlat', () => {
test('returns only files with full paths, no dirs', () => {
const files = [
makeDiffFile('src/tui/App.ts'),
makeDiffFile('src/utils.ts'),
makeDiffFile('README.md'),
];
const visible = flattenFlat(files);
expect(visible).toHaveLength(3);
expect(visible.every((v) => v.type === 'file')).toBe(true);
expect(visible[0].node.name).toBe('src/tui/App.ts');
expect(visible[1].node.name).toBe('src/utils.ts');
expect(visible[2].node.name).toBe('README.md');
});

test('all nodes have depth 0', () => {
const files = [
makeDiffFile('a/b/c.ts'),
makeDiffFile('d.ts'),
];
const visible = flattenFlat(files);
expect(visible.every((v) => v.node.depth === 0)).toBe(true);
});

test('preserves file indices', () => {
const files = [
makeDiffFile('x.ts'),
makeDiffFile('y.ts'),
makeDiffFile('z.ts'),
];
const visible = flattenFlat(files);
expect(visible[0].type === 'file' && visible[0].fileIndex).toBe(0);
expect(visible[1].type === 'file' && visible[1].fileIndex).toBe(1);
expect(visible[2].type === 'file' && visible[2].fileIndex).toBe(2);
});
});