The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): desktop.log stamps lines in local time, like the Python logs
alt-glitch2d9d4abbefa9
diff --git a/apps/desktop/e2e/update/gates.spec.ts b/apps/desktop/e2e/update/gates.spec.tsindex 42b0044bffe..584714eae42 100644--- a/apps/desktop/e2e/update/gates.spec.ts+++ b/apps/desktop/e2e/update/gates.spec.ts@@ -11,7 +11,7 @@ import { gateMatches, KNOWN } from './gates'test('gate signatures match their bug and not neighbouring failures', () => {const real ='"Update now" hands off to the updater and the app quits for it; the app logged:\n' +- '[2026-09-27T01:19:44.583Z] [hermes] [updates] state.db pre-flight failed: Python not found. Update cancelled before backend shutdown.'+ '2026-09-27 01:19:44,583 [hermes] [updates] state.db pre-flight failed: Python not found. Update cancelled before backend shutdown.'expect(gateMatches(KNOWN.preflightPython, real)).toBe(true)diff --git a/apps/desktop/electron/desktop-log-line.test.ts b/apps/desktop/electron/desktop-log-line.test.tsindex 8c1e5a266e4..c400fa3d86f 100644--- a/apps/desktop/electron/desktop-log-line.test.ts+++ b/apps/desktop/electron/desktop-log-line.test.ts@@ -1,16 +1,19 @@import { describe, expect, it } from 'vitest'-import { formatDesktopLogLine } from './desktop-log-line'+import { formatDesktopLogLine, formatLogStamp } from './desktop-log-line'describe('formatDesktopLogLine', () => {- it('prefixes each line with an ISO-8601 timestamp and the hermes tag', () => {- const line = formatDesktopLogLine('[boot] Resolving Hermes backend')+ it('stamps lines with the local wall-clock time, in the shape Python logs use', () => {+ // Built from local components, so the assertion holds in every time zone:+ // the stamp must name the same local moment agent.log would print for it.+ const moment = new Date(2026, 8, 3, 7, 5, 9, 42)+ const line = formatDesktopLogLine('[boot] Resolving Hermes backend', formatLogStamp(moment))- // Shape contract (not a snapshot): every desktop log line starts with- // an ISO timestamp so multi-surface logs are chronologically readable.- // See #84405.- expect(line).toMatch(- /^\[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z\] \[hermes\] \[boot\] Resolving Hermes backend$/- )+ const match = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}),(\d{3}) \[hermes\] (.*)$/.exec(line)++ expect(match).not.toBeNull()+ const [, y, mo, d, h, mi, s, ms, text] = match!+ expect(new Date(+y, +mo - 1, +d, +h, +mi, +s, +ms).getTime()).toBe(moment.getTime())+ expect(text).toBe('[boot] Resolving Hermes backend')})})diff --git a/apps/desktop/electron/desktop-log-line.ts b/apps/desktop/electron/desktop-log-line.tsindex 86db90149ed..ff28c324d30 100644--- a/apps/desktop/electron/desktop-log-line.ts+++ b/apps/desktop/electron/desktop-log-line.ts@@ -2,18 +2,28 @@* Desktop log line formatting shared by every desktop log surface:* `desktop.log`, the in-app "RECENT LOGS" view, and crash forensics.*- * Historically each line was prefixed with just `[hermes] `, so lines from- * different moments were indistinguishable. Every surface now carries an- * ISO-8601 UTC timestamp, matching the Python-side `agent.log` /- * `gateway.log` convention (`2026-07-12 16:22:17,540 INFO ...`). See #84405.+ * The stamp is local time in the `YYYY-MM-DD HH:MM:SS,mmm` shape of Python's+ * default `asctime` (agent.log, gui.log, errors.log), so every file in `logs/`+ * reads on one clock and `hermes logs desktop --since` can parse these lines.+ * See #84405 for why lines carry a stamp at all.*/+const pad = (value: number, width = 2) => String(value).padStart(width, '0')++/** `2026-09-28 13:18:46,062` in the machine's local time zone. */+export function formatLogStamp(date: Date): string {+ const day = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`+ const time = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`++ return `${day} ${time},${pad(date.getMilliseconds(), 3)}`+}+/**- * Format one desktop log line with an ISO-8601 UTC timestamp.+ * Format one desktop log line with a local-time stamp.** `stamp` defaults to now; callers that batch multiple lines (a single* stdout chunk) pass one shared stamp so the group reads as one event.*/-export function formatDesktopLogLine(text: string, stamp = new Date().toISOString()): string {- return `[${stamp}] [hermes] ${text}`+export function formatDesktopLogLine(text: string, stamp = formatLogStamp(new Date())): string {+ return `${stamp} [hermes] ${text}`}diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex d26ecf60120..d3f441207a6 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -204,7 +204,7 @@ import { describeCrashReason, installCrashForensics } from './crash-forensics'import { adoptServedDashboardToken, resolveServedDashboardToken } from './dashboard-token'import { resolveDesktopHermesHome, resolveDesktopUserData } from './data-paths'import { loadOrCreateInstallationId, sshOwnershipId } from './desktop-installation'-import { formatDesktopLogLine } from './desktop-log-line'+import { formatDesktopLogLine, formatLogStamp } from './desktop-log-line'import {createDesktopProfilePreferences,DESKTOP_PROFILE_NAME_RE,@@ -2038,8 +2038,8 @@ function rememberLog(chunk) {}// One timestamp per chunk: lines arriving in the same event happened- // at the same moment. ISO-8601 UTC, matching agent.log/gateway.log.- const stamp = new Date().toISOString()+ // at the same moment. Local time, same shape as agent.log/gui.log.+ const stamp = formatLogStamp(new Date())const lines = text.split(/\r?\n/).map(line => formatDesktopLogLine(line, stamp))hermesLog.push(...lines)