TypeScript
fix(cli): t3 triage points agents at log files that exist (#13685)
Theo Browne7c901a37c4e8
diff --git a/.github/triage/PLAYBOOK.md b/.github/triage/PLAYBOOK.mdindex 39bf3ea0105..32def6bc0c1 100644--- a/.github/triage/PLAYBOOK.md+++ b/.github/triage/PLAYBOOK.md@@ -59,8 +59,9 @@ different code depending on it:Then work from evidence, not assumption. In rough order of value:-- The server log and the trace file (`server.trace.ndjson`) around the time of the- problem. Recent failures usually leave a trail here.+- The trace file (`server.trace.ndjson`) around the time of the problem, plus the+ service log or desktop backend logs from the context file if they exist. Recent+ failures usually leave a trail here.- The provider event log, for problems with claude/codex/cursor sessions.- The SQLite database. Read it freely, but only write when a write is necessaryto fix the problem the user described, and get their explicit permissiondiff --git a/apps/server/src/cli/config.test.ts b/apps/server/src/cli/config.test.tsindex ef7cdd57889..42932b92700 100644--- a/apps/server/src/cli/config.test.ts+++ b/apps/server/src/cli/config.test.ts@@ -508,7 +508,6 @@ it.layer(NodeServices.layer)("cli config resolution", (it) => {resolved.terminalLogsDir,resolved.attachmentsDir,resolved.worktreesDir,- path.dirname(resolved.serverLogPath),path.dirname(resolved.serverTracePath),]) {expect(yield* fs.exists(directory)).toBe(true);diff --git a/apps/server/src/cli/triage.ts b/apps/server/src/cli/triage.tsindex c621d331c40..b408e355011 100644--- a/apps/server/src/cli/triage.ts+++ b/apps/server/src/cli/triage.ts@@ -27,6 +27,7 @@ import * as Schema from "effect/Schema";import { Command, Flag } from "effect/unstable/cli";import packageJson from "../../package.json" with { type: "json" };+import * as BootService from "../cloud/bootService.ts";import * as ServerConfig from "../config.ts";import { resolveBaseDir } from "../os-jank.ts";import { isProcessAlive, readPersistedServerRuntimeState } from "../serverRuntimeState.ts";@@ -201,7 +202,11 @@ export const triageCommand = Command.make("triage", {dbPath: paths.dbPath,settingsPath: paths.settingsPath,logsDir: paths.logsDir,- serverLogPath: paths.serverLogPath,+ // The server writes no log file of its own. Service installs and the+ // desktop app capture its output. The glob covers every desktop backend+ // (such as WSL) and rotated copies; names come from DesktopObservability.ts.+ serviceLogPath: path.join(paths.logsDir, BootService.BOOT_SERVICE_LOG_FILE),+ desktopBackendLogGlob: path.join(paths.logsDir, "server-child*.log*"),serverTracePath: paths.serverTracePath,providerEventLogPath: paths.providerEventLogPath,terminalLogsDir: paths.terminalLogsDir,diff --git a/apps/server/src/cli/triagePrompt.test.ts b/apps/server/src/cli/triagePrompt.test.tsindex bf1ac5dbbe5..fe65bf0dc44 100644--- a/apps/server/src/cli/triagePrompt.test.ts+++ b/apps/server/src/cli/triagePrompt.test.ts@@ -52,7 +52,8 @@ it("context file carries every path the playbook depends on", () => {dbPath: "/home/u/.t3/userdata/state.sqlite",settingsPath: "/home/u/.t3/userdata/settings.json",logsDir: "/home/u/.t3/userdata/logs",- serverLogPath: "/home/u/.t3/userdata/logs/server.log",+ serviceLogPath: "/home/u/.t3/userdata/logs/boot-service.log",+ desktopBackendLogGlob: "/home/u/.t3/userdata/logs/server-child*.log*",serverTracePath: "/home/u/.t3/userdata/logs/server.trace.ndjson",providerEventLogPath: "/home/u/.t3/userdata/logs/provider/events.log",terminalLogsDir: "/home/u/.t3/userdata/logs/terminals",@@ -63,6 +64,8 @@ it("context file carries every path the playbook depends on", () => {});assert.include(context, "/home/u/.t3/userdata/state.sqlite");assert.include(context, "/home/u/.t3/userdata/logs/server.trace.ndjson");+ assert.include(context, "/home/u/.t3/userdata/logs/boot-service.log");+ assert.include(context, "/home/u/.t3/userdata/logs/server-child*.log*");assert.include(context, "/home/u/.t3/userdata/logs/provider/events.log");assert.include(context, "/home/u/.t3/userdata/secrets");assert.include(context, "/home/u/.t3/source");diff --git a/apps/server/src/cli/triagePrompt.ts b/apps/server/src/cli/triagePrompt.tsindex c2b93a1840a..1df71285426 100644--- a/apps/server/src/cli/triagePrompt.ts+++ b/apps/server/src/cli/triagePrompt.ts@@ -71,8 +71,9 @@ different code depending on it:Then work from evidence, not assumption. In rough order of value:-- The server log and the trace file (\`server.trace.ndjson\`) around the time of the- problem. Recent failures usually leave a trail here.+- The trace file (\`server.trace.ndjson\`) around the time of the problem, plus the+ service log or desktop backend logs from the context file if they exist. Recent+ failures usually leave a trail here.- The provider event log, for problems with claude/codex/cursor sessions.- The SQLite database. Read it freely, but only write when a write is necessaryto fix the problem the user described, and get their explicit permission@@ -176,7 +177,8 @@ export interface TriageContextInput {readonly dbPath: string;readonly settingsPath: string;readonly logsDir: string;- readonly serverLogPath: string;+ readonly serviceLogPath: string;+ readonly desktopBackendLogGlob: string;readonly serverTracePath: string;readonly providerEventLogPath: string;readonly terminalLogsDir: string;@@ -205,7 +207,8 @@ Generated by \`t3 triage\` at ${input.generatedAt}.- Database (SQLite; write only with the user's explicit permission): ${input.paths.dbPath}- Settings: ${input.paths.settingsPath}- Logs dir: ${input.paths.logsDir}-- Server log: ${input.paths.serverLogPath}+- Service log (systemd/launchd service installs only): ${input.paths.serviceLogPath}+- Desktop backend logs (glob; one file per backend plus rotated copies; written only when a backend crashes or fails to start): ${input.paths.desktopBackendLogGlob}- Server trace (ndjson): ${input.paths.serverTracePath}- Provider event log: ${input.paths.providerEventLogPath}- Terminal logs: ${input.paths.terminalLogsDir}diff --git a/apps/server/src/cloud/bootService.ts b/apps/server/src/cloud/bootService.tsindex 0a57ed822af..fc8fc1549a6 100644--- a/apps/server/src/cloud/bootService.ts+++ b/apps/server/src/cloud/bootService.ts@@ -43,6 +43,8 @@ const BOOT_SERVICE_UNIT_FILE = `${BOOT_SERVICE_NAME}.service`;const BOOT_SERVICE_LAUNCHD_LABEL = "com.t3tools.t3code.service";const BOOT_SERVICE_PLIST_FILE = `${BOOT_SERVICE_LAUNCHD_LABEL}.plist`;const BOOT_SERVICE_UNIT_ENV = "T3_BOOT_SERVICE_UNIT";+/** File in the logs dir that receives the service's stdout and stderr. `t3 triage` points agents at it. */+export const BOOT_SERVICE_LOG_FILE = "boot-service.log";/** systemd expands `%` specifiers, including in unquoted append-log paths. */function escapeSystemdSpecifiers(value: string): string {@@ -599,7 +601,7 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {environmentPath,});const unitPath = detectedManager?.unitPath ?? "";- const logPath = path.join(input.logsDir, "boot-service.log");+ const logPath = path.join(input.logsDir, BOOT_SERVICE_LOG_FILE);const statePath = path.join(input.baseDir, "runtime", SERVICE_STATE_FILE);const restartPendingPath = path.join(input.baseDir, "runtime", SERVICE_RESTART_PENDING_FILE);const runtimePaths = pinnedRuntimePaths(path, input.baseDir, input.cliVersion, platform);diff --git a/apps/server/src/config.ts b/apps/server/src/config.tsindex 74ffde8efef..d8dad5ae4d2 100644--- a/apps/server/src/config.ts+++ b/apps/server/src/config.ts@@ -44,7 +44,6 @@ export interface ServerDerivedPaths {/** Screenshots the agent asks the collaborative browser to keep for the user. */readonly browserArtifactsDir: string;readonly logsDir: string;- readonly serverLogPath: string;readonly serverTracePath: string;readonly providerLogsDir: string;readonly providerEventLogPath: string;@@ -154,7 +153,6 @@ export const deriveServerPaths = Effect.fn(function* (attachmentsDir,browserArtifactsDir: join(stateDir, "browser-artifacts"),logsDir,- serverLogPath: join(logsDir, "server.log"),serverTracePath: join(logsDir, "server.trace.ndjson"),providerLogsDir,providerEventLogPath: join(providerLogsDir, "events.log"),diff --git a/docs/operations/observability.md b/docs/operations/observability.mdindex 86a65702c27..ffe80bbc81b 100644--- a/docs/operations/observability.md+++ b/docs/operations/observability.md@@ -603,5 +603,3 @@ Current high-value span and metric boundaries include:- logs outside spans are not persisted in the trace file; SSH-managed launch stdout/stderr is stillcaptured in its launcher log- metrics are not snapshotted locally-- the old `serverLogPath` still exists in config for compatibility, but the trace file is the primary- structured persisted artifact