Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/getConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ export type Config = Theme & {
MIN_LINE_WIDTH: number;
WRAP_LINES: boolean;
HIGHLIGHT_LINE_CHANGES: boolean;
INTERACTIVE: boolean;
TREE_WIDTH: number;
};

export const CONFIG_DEFAULTS: Omit<Config, keyof Theme> = {
MIN_LINE_WIDTH: 80,
WRAP_LINES: true,
HIGHLIGHT_LINE_CHANGES: true,
INTERACTIVE: false,
TREE_WIDTH: 30,
};

export function getConfig(gitConfig: GitConfig): Config {
Expand Down
6 changes: 6 additions & 0 deletions src/getGitConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
DEFAULT_MIN_LINE_WIDTH,
DEFAULT_THEME_DIRECTORY,
DEFAULT_THEME_NAME,
DEFAULT_TREE_WIDTH,
GitConfig,
getGitConfig,
} from './getGitConfig';
Expand All @@ -12,6 +13,8 @@ const DEFAULT_CONFIG: GitConfig = {
MIN_LINE_WIDTH: DEFAULT_MIN_LINE_WIDTH,
THEME_NAME: DEFAULT_THEME_NAME,
THEME_DIRECTORY: DEFAULT_THEME_DIRECTORY,
INTERACTIVE: false,
TREE_WIDTH: DEFAULT_TREE_WIDTH,
};

describe('getGitConfig', () => {
Expand All @@ -28,6 +31,7 @@ split-diffs.min-line-width=40
split-diffs.theme-name=arctic
split-diffs.theme-directory=/tmp
split-diffs.syntax-highlighting-theme=dark-plus
split-diffs.tree-width=40
`)
).toEqual({
WRAP_LINES: false,
Expand All @@ -36,6 +40,8 @@ split-diffs.syntax-highlighting-theme=dark-plus
THEME_NAME: 'arctic',
THEME_DIRECTORY: '/tmp',
SYNTAX_HIGHLIGHTING_THEME: 'dark-plus',
INTERACTIVE: false,
TREE_WIDTH: 40,
});
});

Expand Down
15 changes: 15 additions & 0 deletions src/getGitConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export type GitConfig = {
THEME_DIRECTORY: string;
THEME_NAME: string;
SYNTAX_HIGHLIGHTING_THEME?: string;
INTERACTIVE: boolean;
TREE_WIDTH: number;
};

export const DEFAULT_MIN_LINE_WIDTH = 80;
export const DEFAULT_TREE_WIDTH = 30;
export const DEFAULT_THEME_DIRECTORY = path.resolve(
path.dirname(fileURLToPath(import.meta.url)),
'..',
Expand Down Expand Up @@ -49,6 +52,16 @@ export function getGitConfig(configString: string): GitConfig {
// Ignore invalid values
}

let treeWidth = DEFAULT_TREE_WIDTH;
try {
const parsedTreeWidth = parseInt(rawConfig['tree-width'], 10);
if (!isNaN(parsedTreeWidth)) {
treeWidth = parsedTreeWidth;
}
} catch {
// Ignore invalid values
}

return {
MIN_LINE_WIDTH: minLineWidth,
WRAP_LINES: rawConfig['wrap-lines'] !== 'false',
Expand All @@ -57,5 +70,7 @@ export function getGitConfig(configString: string): GitConfig {
rawConfig['theme-directory'] ?? DEFAULT_THEME_DIRECTORY,
THEME_NAME: rawConfig['theme-name'] ?? DEFAULT_THEME_NAME,
SYNTAX_HIGHLIGHTING_THEME: rawConfig['syntax-highlighting-theme'],
INTERACTIVE: rawConfig['interactive'] === 'true',
TREE_WIDTH: treeWidth,
};
}
2 changes: 2 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const TEST_CONFIG: Config = {
MIN_LINE_WIDTH: 60,
WRAP_LINES: false,
HIGHLIGHT_LINE_CHANGES: false,
INTERACTIVE: false,
TREE_WIDTH: 30,
...TEST_THEME,
};

Expand Down
53 changes: 39 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,51 @@ import { getContextForConfig } from './context';
import { getGitConfig } from './getGitConfig';
import { transformContentsStreaming } from './transformContentsStreaming';
import { getConfig } from './getConfig';
import { TuiApp, BORDER_WIDTH } from './tui/TuiApp';
const execAsync = util.promisify(exec);

async function main() {
const { stdout: gitConfigString } = await execAsync('git config -l');
const gitConfig = getGitConfig(gitConfigString);
const config = getConfig(gitConfig);
const context = await getContextForConfig(
config,
chalk,
terminalSize().columns
);
await transformContentsStreaming(context, process.stdin, process.stdout);

// Ensure stdout is fully flushed before exiting
// This is critical when piping to `less` - if we exit before stdout is drained,
// less may not receive all data or may receive it in a broken state
if (process.stdout.writableNeedDrain) {
await new Promise<void>((resolve) => {
process.stdout.once('drain', resolve);
});

let isInteractive =
process.argv.includes('--interactive') ||
process.argv.includes('-i') ||
config.INTERACTIVE;

if (isInteractive && process.platform === 'win32') {
process.stderr.write(
'Interactive mode is not supported on Windows. Falling back to non-interactive mode.\n'
);
isInteractive = false;
}

const termCols = terminalSize().columns;
const screenWidth = isInteractive
? Math.max(1, termCols - config.TREE_WIDTH - BORDER_WIDTH)
: termCols;

const context = await getContextForConfig(config, chalk, screenWidth);

if (isInteractive) {
const app = new TuiApp();
await app.run(context, process.stdin, config.TREE_WIDTH);
} else {
await transformContentsStreaming(
context,
process.stdin,
process.stdout
);

// Ensure stdout is fully flushed before exiting
// This is critical when piping to `less` - if we exit before stdout is drained,
// less may not receive all data or may receive it in a broken state
if (process.stdout.writableNeedDrain) {
await new Promise<void>((resolve) => {
process.stdout.once('drain', resolve);
});
}
}
}

Expand Down
Loading