Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Default to using Bun instead of Node.js:
- Fix: Patches `build/parse-keypress.js` to correctly map `\x7f` to backspace
- Applied automatically during `bun install` via `patchedDependencies` in package.json
- Patch file: `patches/ink@6.2.0.patch`
- **ink-file-picker@0.3.2**: Pinned exact version powering the Import Config file browser (`src/tui/components/ImportConfigDialog.tsx`). It consumes all printable keys for type-ahead filtering, so extra dialog shortcuts must use Ctrl combos.
- **Build process**: Two-step build using `bun run build`
1. `bun build`: Bundles src/ccstatusline.ts into dist/ccstatusline.js targeting Node.js 14+
2. `postbuild`: Runs scripts/replace-version.ts to replace `__PACKAGE_VERSION__` placeholder with actual version from package.json
Expand Down
50 changes: 10 additions & 40 deletions bun.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"globals": "^17.3.0",
"https-proxy-agent": "^8.0.0",
"ink": "6.2.0",
"ink-file-picker": "0.3.2",
"ink-gradient": "^4.0.0",
"ink-select-input": "^6.2.0",
"pluralize": "^8.0.0",
Expand Down Expand Up @@ -90,6 +91,7 @@
"unrs-resolver"
],
"patchedDependencies": {
"ink@6.2.0": "patches/ink@6.2.0.patch"
"ink@6.2.0": "patches/ink@6.2.0.patch",
"ink-file-picker@0.3.2": "patches/ink-file-picker@0.3.2.patch"
}
}
65 changes: 65 additions & 0 deletions patches/ink-file-picker@0.3.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/dist/index.d.ts b/dist/index.d.ts
index 13e77df..07ccd58 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -109,7 +109,10 @@ type FilePickerProps = {
* Custom theme overrides. Merged with the default theme.
* Allows customizing styles (colors, layout) and config (icons, separators).
*/
- readonly theme?: Partial<FilePickerTheme>;
+ readonly theme?: {
+ readonly styles?: Partial<FilePickerThemeStyles>;
+ readonly config?: Partial<FilePickerTheme['config']>;
+ };
};
type FilePickerThemeStyles = {
container: () => BoxProps;
@@ -147,6 +150,7 @@ type FilePickerTheme = {
separatorChar: string;
directoryTrail: string;
symlinkIndicator: string;
+ focusIndicator?: string;
};
};
type FilePickerMode = 'loading' | 'browsing' | 'filtering' | 'error';
diff --git a/dist/index.js b/dist/index.js
index 3d7ede4..f29d299 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -750,7 +750,7 @@ function FilePickerEntry({
"aria-role": "listitem",
"aria-state": { selected: isSelected || isFocused },
children: [
- isFocused ? /* @__PURE__ */ jsx(Text, { ...styles.focusIndicator(), "aria-hidden": true, children: ">" }) : /* @__PURE__ */ jsx(Text, { "aria-hidden": true, children: " " }),
+ isFocused ? /* @__PURE__ */ jsx(Text, { ...styles.focusIndicator(), "aria-hidden": true, children: config.focusIndicator ?? ">" }) : /* @__PURE__ */ jsx(Text, { "aria-hidden": true, children: " " }),
multiSelect && /* @__PURE__ */ jsx(Box, { "aria-role": "checkbox", "aria-state": { checked: isSelected }, children: /* @__PURE__ */ jsx(Text, { ...styles.selectedIndicator(), "aria-hidden": true, children: isSelected ? "[x]" : "[ ]" }) }),
/* @__PURE__ */ jsx(Text, { ...styles.entryIcon({ kind: entry.kind }), "aria-hidden": true, children: icon }),
/* @__PURE__ */ jsx(
@@ -805,8 +805,7 @@ function FilePickerHeader({
return /* @__PURE__ */ jsxs2(Box2, { ...styles.header(), children: [
/* @__PURE__ */ jsxs2(Text2, { ...styles.headerPath(), "aria-label": `Current directory: ${currentPath}`, children: [
/* @__PURE__ */ jsxs2(Text2, { "aria-hidden": true, children: [
- config.directoryIcon,
- " "
+ "Folder: "
] }),
truncatePath(currentPath, 50)
] }),
@@ -831,7 +830,7 @@ function FilePickerFooter({
const hints = [];
if (mode === "filtering") {
hints.push({ key: "Esc", action: "clear filter" });
- hints.push({ key: "Enter", action: "open" });
+ hints.push({ key: "Enter", action: "open/select" });
} else if (mode === "error") {
hints.push({ key: "r", action: "retry" });
hints.push({ key: "Esc", action: "go back" });
@@ -1042,7 +1041,7 @@ function FilePicker(props) {
styles
}
),
- (state.mode === "browsing" || state.mode === "filtering") && /* @__PURE__ */ jsx5(Box5, { "aria-role": "list", children: state.filteredEntries.length === 0 ? /* @__PURE__ */ jsx5(Box5, { "aria-role": "listitem", children: /* @__PURE__ */ jsx5(Text5, { ...styles.emptyDirectory(), children: state.filterText ? "No matches" : "Empty directory" }) }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
+ (state.mode === "browsing" || state.mode === "filtering") && /* @__PURE__ */ jsx5(Box5, { "aria-role": "list", flexDirection: "column", children: state.filteredEntries.length === 0 ? /* @__PURE__ */ jsx5(Box5, { "aria-role": "listitem", children: /* @__PURE__ */ jsx5(Text5, { ...styles.emptyDirectory(), children: state.filterText ? "No matches" : "Empty directory" }) }) : /* @__PURE__ */ jsxs5(Fragment, { children: [
state.visibleFromIndex > 0 && /* @__PURE__ */ jsxs5(Text5, { dimColor: true, "aria-hidden": true, children: [
" ",
state.visibleFromIndex,
91 changes: 80 additions & 11 deletions src/tui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useInput
} from 'ink';
import Gradient from 'ink-gradient';
import * as path from 'path';
import React, {
useCallback,
useEffect,
Expand Down Expand Up @@ -40,11 +41,17 @@ import {
getConfigPath,
isCustomConfigPath,
loadSettings,
normalizeUserPath,
saveInstallationMetadata,
saveSettings,
validateImportFile,
type ImportValidationResult
} from '../utils/config';
import {
DEFAULT_EXPORT_FILE_NAME,
getExportConfirmMessage,
getExportTargetStatus
} from '../utils/export-target';
import {
inspectGlobalCommandResolution,
isPathInsideDir
Expand Down Expand Up @@ -483,6 +490,10 @@ export const App: React.FC = () => {
const [commandAvailability] = useState(() => getPackageCommandAvailability());
const [updateCheckerState, setUpdateCheckerState] = useState<UpdateCheckerState>({ status: 'checking' });
const [flowNotice, setFlowNotice] = useState<FlowNoticeState | null>(null);
const [exportDraft, setExportDraft] = useState<{ dir: string | undefined; fileName: string }>({
dir: undefined,
fileName: DEFAULT_EXPORT_FILE_NAME
});
const [globalPackageInstallations, setGlobalPackageInstallations] = useState<GlobalPackageInstallation[]>([]);
const [updatesReturnScreen, setUpdatesReturnScreen] = useState<'main' | 'manageInstallation'>('main');
const [hasLoadedClaudeStatus, setHasLoadedClaudeStatus] = useState(false);
Expand Down Expand Up @@ -783,23 +794,79 @@ export const App: React.FC = () => {
}, [getGlobalResolutionWarning]);

const handleExportConfig = useCallback(async (filePath: string) => {
try {
if (!settings) {
return;
}
await exportConfig(settings, filePath);
setFlashMessage({ text: `Config exported to ${filePath}`, color: 'green' });
} catch (err) {
if (!settings) {
return;
}

const target = normalizeUserPath(filePath);
const status = getExportTargetStatus(target);

// Remember folder and name so a declined confirm (or an error) returns to the same dialog state.
// A missing folder is not remembered: the picker cannot start in a folder that does not exist.
const knownDir = status === 'ok' || status === 'exists' || status === 'is-directory' || status === 'not-regular';
setExportDraft(prev => ({
dir: knownDir ? path.dirname(target) : prev.dir,
fileName: path.basename(target)
}));

const failToDialog = (message: string) => {
setFlowNotice({
title: 'Export Failed',
message: err instanceof Error ? err.message : String(err),
message,
color: 'red',
continueScreen: 'main'
continueScreen: 'exportConfig'
});
setScreen('flowNotice');
return;
};

const runExport = async (createDir: boolean, overwrite: boolean) => {
try {
await exportConfig(settings, target, { createDir, overwrite });
} catch (err) {
setConfirmDialog(null);
const code = (err as NodeJS.ErrnoException | undefined)?.code;
failToDialog(code === 'EEXIST'
? `${target} was created by something else just now. Export again to overwrite it.`
: err instanceof Error ? err.message : String(err));
return;
}
setConfirmDialog(null);
setFlashMessage({ text: `Config exported to ${target}`, color: 'green' });
setScreen('main');
};

switch (status) {
case 'ok':
await runExport(false, false);
return;
case 'is-directory':
failToDialog(`${target} is a folder. Choose a file name.`);
return;
case 'parent-not-directory':
failToDialog(`${path.dirname(target)} is not a folder.`);
return;
case 'not-regular':
failToDialog(`${target} is not a regular file (symlink, device or pipe). Choose another name.`);
return;
case 'exists':
case 'missing-dir': {
// ConfirmDialog stays mounted until the awaited write finishes; ignore a second Yes.
let started = false;
setConfirmDialog({
message: getExportConfirmMessage(status, target),
cancelScreen: 'exportConfig',
action: async () => {
if (started) {
return;
}
started = true;
await runExport(status === 'missing-dir', status === 'exists');
}
});
setScreen('confirm');
return;
}
}
setScreen('main');
}, [settings]);

const handleImportFileChosen = useCallback(async (filePath: string) => {
Expand Down Expand Up @@ -1451,6 +1518,8 @@ export const App: React.FC = () => {

{screen === 'exportConfig' && (
<ExportConfigDialog
initialDir={exportDraft.dir}
initialFileName={exportDraft.fileName}
onExport={(filePath) => { void handleExportConfig(filePath); }}
onCancel={() => { setScreen('main'); }}
/>
Expand Down
Loading
Loading