Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: CLI spinner + 30min timeout for large repo ingestion

riley0227b3dc26251224
diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.ts
index 8b2e8c17..46dbe070 100644
--- a/ix-cli/src/cli/commands/ingest.ts
+++ b/ix-cli/src/cli/commands/ingest.ts
@@ -12,32 +12,50 @@ export function registerIngestCommand(program: Command): void {
.action(async (path: string, opts: { recursive?: boolean; format: string }) => {
const client = new IxClient(getEndpoint());
const start = performance.now();
- const result = await client.ingest(path, opts.recursive);
- const elapsed = ((performance.now() - start) / 1000).toFixed(2);
- if (opts.format === "json") {
- console.log(JSON.stringify({ ...result, elapsedSeconds: parseFloat(elapsed) }, null, 2));
- } else {
- console.log(chalk.bold("\nIngest summary"));
- console.log(` processed: ${result.patchesApplied} files (${elapsed}s)`);
- console.log(` discovered: ${result.filesProcessed} files`);
- if (result.skipReasons) {
- const sr = result.skipReasons;
- if (sr.unchanged > 0) console.log(` ${chalk.dim("skipped unchanged:")} ${sr.unchanged}`);
- if (sr.emptyFile > 0) console.log(` ${chalk.dim("skipped empty:")} ${sr.emptyFile}`);
- if (sr.parseError > 0) console.log(` ${chalk.red("parse errors:")} ${sr.parseError}`);
- if (sr.tooLarge > 0) console.log(` ${chalk.dim("skipped too large:")} ${sr.tooLarge}`);
- } else if (result.filesSkipped) {
- console.log(` ${chalk.dim("skipped:")} ${result.filesSkipped} unchanged files`);
+
+ // Show elapsed time while waiting
+ const spinner = ["\u28CB", "\u28D9", "\u28F9", "\u28F8", "\u28FC", "\u28F4", "\u28E6", "\u28E7", "\u28C7", "\u28CF"];
+ let spinIdx = 0;
+ const interval = opts.format === "text" ? setInterval(() => {
+ const elapsed = ((performance.now() - start) / 1000).toFixed(0);
+ process.stderr.write(`\r${spinner[spinIdx++ % spinner.length]} Ingesting... ${elapsed}s`);
+ }, 200) : null;
+
+ try {
+ const result = await client.ingest(path, opts.recursive);
+ if (interval) {
+ clearInterval(interval);
+ process.stderr.write("\r" + " ".repeat(40) + "\r");
}
- console.log(` rev: ${result.latestRev}`);
+ const elapsed = ((performance.now() - start) / 1000).toFixed(2);
+
+ if (opts.format === "json") {
+ console.log(JSON.stringify({ ...result, elapsedSeconds: parseFloat(elapsed) }, null, 2));
+ } else {
+ console.log(chalk.bold("\nIngest summary"));
+ console.log(` processed: ${result.patchesApplied} files (${elapsed}s)`);
+ console.log(` discovered: ${result.filesProcessed} files`);
+ if (result.skipReasons) {
+ const sr = result.skipReasons;
+ if (sr.unchanged > 0) console.log(` ${chalk.dim("skipped unchanged:")} ${sr.unchanged}`);
+ if (sr.emptyFile > 0) console.log(` ${chalk.dim("skipped empty:")} ${sr.emptyFile}`);
+ if (sr.parseError > 0) console.log(` ${chalk.red("parse errors:")} ${sr.parseError}`);
+ if (sr.tooLarge > 0) console.log(` ${chalk.dim("skipped too large:")} ${sr.tooLarge}`);
+ } else if (result.filesSkipped) {
+ console.log(` ${chalk.dim("skipped:")} ${result.filesSkipped} unchanged files`);
+ }
+ console.log(` rev: ${result.latestRev}`);
- if (result.patchesApplied === 0 && result.filesProcessed === 0) {
- console.log(chalk.yellow("\n ⚠ No files ingested. The path may be outside the project root,"));
- console.log(chalk.yellow(" contain no supported file types, or not exist."));
- } else if (result.patchesApplied === 0 && result.filesProcessed > 0) {
- console.log(chalk.dim("\n All files unchanged since last ingest."));
+ if (result.patchesApplied === 0 && result.filesProcessed === 0) {
+ console.log(chalk.yellow("\n Warning: No files ingested. The path may be outside the project root,"));
+ console.log(chalk.yellow(" contain no supported file types, or not exist."));
+ } else if (result.patchesApplied === 0 && result.filesProcessed > 0) {
+ console.log(chalk.dim("\n All files unchanged since last ingest."));
+ }
+ console.log();
}
- console.log();
+ } finally {
+ if (interval) clearInterval(interval);
}
});
}
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index 3a732e93..e1fb09da 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -19,7 +19,17 @@ export class IxClient {
}
async ingest(path: string, recursive?: boolean): Promise<IngestResult> {
- return this.post("/v1/ingest", { path, recursive });
+ const resp = await fetch(`${this.endpoint}/v1/ingest`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ path, recursive }),
+ signal: AbortSignal.timeout(30 * 60 * 1000), // 30 minute timeout for large repos
+ });
+ if (!resp.ok) {
+ const text = await resp.text();
+ throw new Error(`${resp.status}: ${text}`);
+ }
+ return resp.json() as Promise<IngestResult>;
}
async decide(