Skip to content

The agent that grows with you

fix(desktop): error card's Open Logs reveals the session owner's logs dir (#119080)

teknium19f8fb4a5b92a
diff --git a/apps/desktop/electron/fs-ipc.test.ts b/apps/desktop/electron/fs-ipc.test.ts
index 9c25c461d60..eb09acc9a3c 100644
--- a/apps/desktop/electron/fs-ipc.test.ts
+++ b/apps/desktop/electron/fs-ipc.test.ts
@@ -28,7 +28,7 @@ vi.mock('electron', () => ({
vi.mock('./desktop-plugin-install', () => ({ installDesktopPluginFromGit: vi.fn(), probePluginRepo: vi.fn() }))
vi.mock('./desktop-plugins-root', () => ({
DESKTOP_PLUGINS_DIR: 'desktop-plugins',
- ensureDir: vi.fn(),
+ ensureDir: vi.fn(async (dir: string) => dir),
migrateProfileScopedDesktopPlugins: vi.fn(),
reconcileUnifiedDesktopHalves: vi.fn()
}))
@@ -39,7 +39,7 @@ const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-fs-ipc-'))
registerFsIpc({
hermesHome: scratch,
- readActiveDesktopProfile: () => null,
+ readActiveDesktopProfile: () => 'launch-profile',
// `~/` resolves under the scratch dir so tilde paths can be exercised.
expandUserPath: value => (value.startsWith('~/') ? path.join(scratch, value.slice(2)) : value),
resolveRequestedPathForIpc: value => value,
@@ -80,3 +80,19 @@ describe('hermes:fs:reveal', () => {
expect(electron.showItemInFolder).toHaveBeenCalledWith(here)
})
})
+
+// A pooled backend serves several profile homes; the active Desktop profile
+// is the LAUNCH one, so the error card names the profile owning the failing
+// session and the root resolves under THAT home (#119080).
+describe('hermes:fs:logsRoot', () => {
+ const logsRoot = (profile?: string) => electron.handlers.get('hermes:fs:logsRoot')!({}, profile)
+
+ it('resolves the logs dir of the profile that owns the session', async () => {
+ await expect(logsRoot('finex')).resolves.toBe(path.join(scratch, 'profiles', 'finex', 'logs'))
+ await expect(logsRoot('default')).resolves.toBe(path.join(scratch, 'logs'))
+ })
+
+ it('falls back to the active Desktop profile when no owner is named', async () => {
+ await expect(logsRoot()).resolves.toBe(path.join(scratch, 'profiles', 'launch-profile', 'logs'))
+ })
+})
diff --git a/apps/desktop/electron/fs-ipc.ts b/apps/desktop/electron/fs-ipc.ts
index 3c41dd8614e..9e44d17328c 100644
--- a/apps/desktop/electron/fs-ipc.ts
+++ b/apps/desktop/electron/fs-ipc.ts
@@ -99,8 +99,8 @@ export function registerFsIpc({
// Profile-scoped roots (agent plugins, logs) live under profiles/<name>/ for a
// named Desktop profile — they belong to THAT agent. 'default'/unset pins the
// global root.
- async function localPluginsRoot(dirName: string): Promise<string> {
- const profile = readActiveDesktopProfile()
+ async function localPluginsRoot(dirName: string, owner?: unknown): Promise<string> {
+ const profile = (typeof owner === 'string' && owner.trim()) || readActiveDesktopProfile()
const base = profile && profile !== 'default' ? path.join(hermesHome, 'profiles', profile) : hermesHome
return ensureDir(path.join(base, dirName))
@@ -133,8 +133,11 @@ export function registerFsIpc({
// The LOCAL logs root (`<HERMES_HOME>/logs`, profile-aware) — the error
// card's "Open Logs" action reveals agent.log/gateway.log without the user
// knowing where HERMES_HOME lives. Same Electron-local resolution as the
- // plugin roots: valid in every connection mode, created on demand.
- ipcMain.handle('hermes:fs:logsRoot', async () => localPluginsRoot('logs'))
+ // plugin roots: valid in every connection mode, created on demand. The
+ // caller names the profile that OWNS the failing session: a pooled backend
+ // serves many profile homes, and the active Desktop profile is the launch
+ // one, not the one whose agent.log holds the failure (#119080).
+ ipcMain.handle('hermes:fs:logsRoot', async (_event, profile) => localPluginsRoot('logs', profile))
ipcMain.handle('hermes:plugin:probe', async (_event, payload) => {
const identifier = String(payload?.identifier || payload?.repo || '').trim()
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index edf6c069ae7..6b29866bbbb 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -426,7 +426,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
openDir: dirPath => ipcRenderer.invoke('hermes:fs:openDir', dirPath),
desktopPluginsRoot: () => ipcRenderer.invoke('hermes:fs:desktopPluginsRoot'),
reconcileDesktopPlugins: () => ipcRenderer.invoke('hermes:fs:reconcileDesktopPlugins'),
- logsRoot: () => ipcRenderer.invoke('hermes:fs:logsRoot'),
+ logsRoot: (profile?: string) => ipcRenderer.invoke('hermes:fs:logsRoot', profile),
renamePath: (targetPath, newName) => ipcRenderer.invoke('hermes:fs:rename', targetPath, newName),
writeTextFile: (filePath, content) => ipcRenderer.invoke('hermes:fs:writeText', filePath, content),
trashPath: targetPath => ipcRenderer.invoke('hermes:fs:trash', targetPath),
diff --git a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx
index 1ff8ad15baa..6f9d37eff9e 100644
--- a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx
+++ b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx
@@ -835,10 +835,14 @@ const ErrorRecoveryActions: FC = () => {
// Reveal a local folder through Electron; `logsRoot` is the profile's
// HERMES_HOME/logs, and its parent is the Hermes data folder itself (what
- // the user needs to see to free space after a disk-full failure).
+ // the user needs to see to free space after a disk-full failure). Resolved
+ // for the profile that OWNS this session (a tile / Bot chat names it in its
+ // composer scope), not the pooled backend's launch profile (#119080).
+ const ownerProfile = useComposerScope().profile || gatewayProfile
+
const openLocalDir = useCallback(async (resolve: (logsRoot: string) => string, failedMessage: string) => {
try {
- const root = await window.hermesDesktop?.logsRoot?.()
+ const root = await window.hermesDesktop?.logsRoot?.(normalizeProfileKey(ownerProfile))
if (!root) {
notifyError(new Error('logs root unavailable'), failedMessage)
@@ -854,7 +858,7 @@ const ErrorRecoveryActions: FC = () => {
} catch (error) {
notifyError(error, failedMessage)
}
- }, [])
+ }, [ownerProfile])
const openLogs = useCallback(
() => openLocalDir(root => root, copy.errorOpenLogsFailed),
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index c44ef0720ab..5f2b5d0d47e 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -433,8 +433,9 @@ declare global {
desktopPluginsRoot?: () => Promise<string>
/** Refresh unified packages' desktop halves and return the touched paths. */
reconcileDesktopPlugins?: () => Promise<string[]>
- /** LOCAL `<HERMES_HOME>/logs` (profile-aware) — error card "Open Logs". */
- logsRoot?: () => Promise<string>
+ /** LOCAL `<HERMES_HOME>/logs` of `profile` (default: the active Desktop
+ * profile) — error card "Open Logs". */
+ logsRoot?: (profile?: string) => Promise<string>
// Local AGENT-plugin root (<HERMES_HOME>/plugins), same Electron-local
// resolution. The disk door also scans it for `<name>/desktop/plugin.js`
// so one agent-plugin package can ship a desktop UI half. Optional: