diff --git a/apps/server/src/project/AgentSessionScanner.test.ts b/apps/server/src/project/AgentSessionScanner.test.ts index 9c62ddb1a2b84..aeb01138fb01b 100644 --- a/apps/server/src/project/AgentSessionScanner.test.ts +++ b/apps/server/src/project/AgentSessionScanner.test.ts @@ -973,9 +973,46 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { }), ); + it.effect("lists only projects with conversations inside the import window", () => + Effect.gen(function* () { + const path = yield* Path.Path; + const nowMs = Date.parse("2026-08-24T12:00:00.000Z"); + yield* TestClock.setTime(nowMs); + const claudeHomePath = yield* makeTempDir("t3code-window-claude-"); + const codexHomePath = yield* makeTempDir("t3code-window-codex-"); + const mixedWorkspace = yield* makeTempDir("t3code-window-mixed-"); + const olderWorkspace = yield* makeTempDir("t3code-window-older-"); + + for (const [workspace, name, ageDays] of [ + [mixedWorkspace, "recent", 1], + [mixedWorkspace, "old", 31], + [olderWorkspace, "older", 45], + [olderWorkspace, "oldest", 60], + ] as const) { + yield* writeTranscript({ + filePath: path.join( + claudeHomePath, + "projects", + `-${path.basename(workspace)}`, + `${name}.jsonl`, + ), + contents: claudeSessionLine(workspace), + mtimeMs: nowMs - ageDays * 24 * 60 * 60 * 1000, + }); + } + + const result = yield* runScan({ claudeHomePath, codexHomePath }); + + expect(result.candidates.map(({ path, threadCount }) => ({ path, threadCount }))).toEqual([ + { path: mixedWorkspace, threadCount: 1 }, + ]); + }), + ); + it.effect("drops candidates whose directory no longer exists", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); @@ -994,6 +1031,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("excludes the home directory, temporary root, and T3 data directory", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const configBaseDir = yield* makeTempDir("t3code-scanner-base-"); @@ -1021,6 +1059,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("excludes T3-managed worktree sandboxes", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const fileSystem = yield* FileSystem.FileSystem; @@ -1042,6 +1081,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("folds linked git worktrees into their checkout and reports real origins", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-10T00:00:00.000Z")); const fileSystem = yield* FileSystem.FileSystem; const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); @@ -1301,6 +1341,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("excludes sandboxes under the configured worktrees dir without .t3 in the path", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const configBaseDir = yield* makeTempDir("t3code-scanner-base-"); @@ -1323,6 +1364,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("excludes sandboxes reached through a symlink into the worktrees dir", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const configBaseDir = yield* makeTempDir("t3code-scanner-base-"); @@ -1348,6 +1390,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("finds the cwd on a later line when the first records carry none", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const workspace = yield* makeTempDir("t3code-workspace-"); @@ -1368,6 +1411,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("reads a complete transcript record at the exact chunk boundary", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-01-02T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const workspace = yield* makeTempDir("t3code-workspace-"); @@ -1392,6 +1436,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("skips malformed transcripts without failing the scan", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-05-04T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const workspace = yield* makeTempDir("t3code-workspace-"); @@ -1432,6 +1477,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-05-04T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const workspace = yield* makeTempDir("t3code-workspace-"); @@ -1462,6 +1508,7 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { it.effect("discovers projects whose Codex rollouts are zstd-compressed", () => Effect.gen(function* () { const path = yield* Path.Path; + yield* TestClock.setTime(Date.parse("2026-05-04T00:00:00.000Z")); const claudeHomePath = yield* makeTempDir("t3code-claude-home-"); const codexHomePath = yield* makeTempDir("t3code-codex-home-"); const workspace = yield* makeTempDir("t3code-workspace-"); diff --git a/apps/server/src/project/AgentSessionScanner.ts b/apps/server/src/project/AgentSessionScanner.ts index 1e300d1fe0410..03f3725468712 100644 --- a/apps/server/src/project/AgentSessionScanner.ts +++ b/apps/server/src/project/AgentSessionScanner.ts @@ -1881,7 +1881,16 @@ export const make = Effect.gen(function* () { const scan: AgentSessionScanner["Service"]["scan"] = Effect.gen(function* () { cachedCandidates = yield* collectCandidates(); - const { candidates: raw, truncated } = cachedCandidates; + const { candidates: collected, truncated } = cachedCandidates; + // Import skips conversations older than the window, so only those inside it count toward a + // project. Future-dated files still count, so clock skew cannot hide a project. + const cutoffMs = DateTime.toEpochMillis(yield* DateTime.now) - RECENT_THREAD_WINDOW_MS; + const raw = collected.flatMap((candidate) => { + const threadCount = candidate.transcripts.filter( + (transcript) => transcript.mtimeMs !== null && transcript.mtimeMs >= cutoffMs, + ).length; + return threadCount === 0 ? [] : [{ ...candidate, threadCount }]; + }); const merged = new Map< string, diff --git a/docs/user/welcome-page.md b/docs/user/welcome-page.md index a914349694156..4f0f4a1b57d5b 100644 --- a/docs/user/welcome-page.md +++ b/docs/user/welcome-page.md @@ -64,13 +64,14 @@ app with a code from **Settings → Sharing & access**. ## Projects -T3 Code finds directories that Claude Code, Codex or Pi has used. Git repositories -are listed first, newest activity on top. When the remote is on GitHub, the -group shows the repository as `owner/name`. Clones with the same remote share -one group. Directories that are not git repositories sit under "Other folders". - -The page offers git repositories active within the last 30 days with at least -three conversations, already checked. Projects already in T3 Code are not checked +T3 Code finds directories that Claude Code, Codex or Pi has used in the last 30 +days. Git repositories are listed first, newest activity on top. When the remote +is on GitHub, the group shows the repository as `owner/name`. Clones with the +same remote share one group. Directories that are not git repositories sit under +"Other folders". + +The page offers git repositories with at least three conversations in that time, +already checked. Projects already in T3 Code are not checked again. Uncheck the box to start without them, or select **Review all** to pick from everything found, with "Select all" and "Select none". Linked worktrees of bare repositories