Skip to content

Commit c3027b2

Browse files
authored
Merge pull request #63 from Typhon0/fix/quick-start-linked-cases
Good catch — quick-start was ignoring linked-cases.json. Thanks @Typhon0!
2 parents ea1c2ee + 0b231ed commit c3027b2

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/web/routes/session-routes.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { FastifyInstance } from 'fastify';
88
import { join, dirname } from 'node:path';
9+
import { homedir } from 'node:os';
910
import { existsSync, statSync, mkdirSync, writeFileSync } from 'node:fs';
1011
import { execFile } from 'node:child_process';
1112
import fs from 'node:fs/promises';
@@ -53,6 +54,9 @@ import { RunSummaryTracker } from '../../run-summary.js';
5354

5455
import { MAX_INPUT_LENGTH, MAX_SESSION_NAME_LENGTH } from '../../config/terminal-limits.js';
5556

57+
// Path to linked-cases registry (same file used by case-routes resolveCasePath)
58+
const LINKED_CASES_FILE = join(homedir(), '.codeman', 'linked-cases.json');
59+
5660
// Pre-compiled regex for terminal buffer cleaning (avoids per-request compilation)
5761
// eslint-disable-next-line no-control-regex
5862
const CLAUDE_BANNER_PATTERN = /\x1b\[1mClaud/;
@@ -919,12 +923,23 @@ export function registerSessionRoutes(
919923
}
920924
}
921925

922-
const casePath = validatePathWithinBase(caseName, CASES_DIR);
926+
// Resolve case path: check linked-cases registry first, then fall back to CASES_DIR.
927+
// This mirrors the behaviour of resolveCasePath() in case-routes so that linked
928+
// external project directories are honoured by quick-start just like regular case routes.
929+
let linkedCases: Record<string, string> = {};
930+
try {
931+
const raw = await fs.readFile(LINKED_CASES_FILE, 'utf-8');
932+
linkedCases = JSON.parse(raw);
933+
} catch {
934+
// File missing or unparseable — treat as empty registry
935+
}
936+
const linkedCasePath = linkedCases[caseName];
937+
const casePath = linkedCasePath || validatePathWithinBase(caseName, CASES_DIR);
923938
if (!casePath) {
924939
return createErrorResponse(ApiErrorCode.INVALID_INPUT, 'Invalid case path');
925940
}
926941

927-
// Create case folder and CLAUDE.md if it doesn't exist
942+
// Create case folder and CLAUDE.md if it doesn't exist (only for non-linked cases)
928943
if (!existsSync(casePath)) {
929944
try {
930945
mkdirSync(casePath, { recursive: true });
@@ -1098,7 +1113,7 @@ export function registerSessionRoutes(
10981113
text.length < 8
10991114
)
11001115
continue;
1101-
return text.length > MAX_PROMPT_LEN ? text.slice(0, MAX_PROMPT_LEN) + '' : text;
1116+
return text.length > MAX_PROMPT_LEN ? text.slice(0, MAX_PROMPT_LEN) + '\u2026' : text;
11021117
} catch {
11031118
// Malformed line — skip
11041119
}

0 commit comments

Comments
 (0)