Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(remote): serialize structured log data via JSON instead of String

vastsafbd68b1c49f2
diff --git a/apps/desktop/electron/main/bootstrap/startup.ts b/apps/desktop/electron/main/bootstrap/startup.ts
index b55f39539..81676a380 100644
--- a/apps/desktop/electron/main/bootstrap/startup.ts
+++ b/apps/desktop/electron/main/bootstrap/startup.ts
@@ -38,6 +38,23 @@ type IpcInvoker = (
args?: readonly unknown[],
) => Promise<unknown>;
+/**
+ * The remote-host modules pass their log `data` as a structured object (e.g.
+ * `{hostKey, error}`); a bare `String(data)` prints `[object Object]` and
+ * loses the context. Errors keep their `String(error)` shape ("Error: ..."),
+ * plain strings pass through, everything else JSON-stringifies.
+ */
+function formatRemoteLogData(data: unknown): string | undefined {
+ if (data === undefined) return undefined;
+ if (typeof data === "string") return data;
+ if (data instanceof Error) return String(data);
+ try {
+ return JSON.stringify(data);
+ } catch {
+ return String(data);
+ }
+}
+
export type StartupState = {
applicationBooted: boolean;
closeBehavior: CloseBehavior;
@@ -168,7 +185,7 @@ export function registerApplicationStartup(deps: StartupDependencies): void {
// sessions here once paired (later stages).
state.backendRouter = createBackendRouter({
log: (level, message, data) =>
- logger.app("runtime", level, message, { data: data === undefined ? undefined : String(data) }),
+ logger.app("runtime", level, message, { data: formatRemoteLogData(data) }),
});
// Every paired remote `pi-host` opens against the router this boot just
// created. An empty registry (default install with no user pairing) makes
@@ -188,7 +205,7 @@ export function registerApplicationStartup(deps: StartupDependencies): void {
emit: sendToRenderer,
clientInfo: { name: APP_NAME, version: APP_VERSION },
log: (level, message, data) =>
- logger.app("runtime", level, message, { data: data === undefined ? undefined : String(data) }),
+ logger.app("runtime", level, message, { data: formatRemoteLogData(data) }),
});
setActiveRemoteHostsBoot(remoteHostsBoot);
// Boot in the background: a slow or unreachable host must not delay the