feat(ui): add runtime logger and replace console usage

This commit is contained in:
Shantur Rathore
2025-12-05 15:07:49 +00:00
parent 49143bd049
commit 971abe24d7
44 changed files with 406 additions and 138 deletions

View File

@@ -8,6 +8,9 @@ import { keyboardRegistry } from "../keyboard-registry"
import { abortSession, getSessions, isSessionBusy } from "../../stores/sessions"
import { showCommandPalette, hideCommandPalette } from "../../stores/command-palette"
import type { Instance } from "../../types/instance"
import { getLogger } from "../logger"
const log = getLogger("actions")
interface UseAppLifecycleOptions {
setEscapeInDebounce: (value: boolean) => void
@@ -115,9 +118,9 @@ export function useAppLifecycle(options: UseAppLifecycleOptions) {
try {
await abortSession(instance.id, sessionId)
console.log("Session aborted successfully")
log.info("Session aborted successfully", { instanceId: instance.id, sessionId })
} catch (error) {
console.error("Failed to abort session:", error)
log.error("Failed to abort session", error)
}
},
() => {

View File

@@ -17,6 +17,9 @@ import type { Instance } from "../../types/instance"
import type { MessageRecord } from "../../stores/message-v2/types"
import { messageStoreBus } from "../../stores/message-v2/bus"
import { cleanupBlankSessions } from "../../stores/session-state"
import { getLogger } from "../logger"
const log = getLogger("actions")
export interface UseCommandsOptions {
preferences: Accessor<Preferences>
@@ -236,15 +239,16 @@ export function useCommands(options: UseCommandsOptions) {
modelID: session.model.modelId,
},
})
} catch (error: unknown) {
} catch (error) {
setSessionCompactionState(instance.id, sessionId, false)
console.error("Failed to compact session:", error)
log.error("Failed to compact session", error)
const message = error instanceof Error ? error.message : "Failed to compact session"
showAlertDialog(`Compact failed: ${message}`, {
title: "Compact failed",
variant: "error",
})
}
},
})
@@ -322,12 +326,13 @@ export function useCommands(options: UseCommandsOptions) {
}
}
} catch (error) {
console.error("Failed to revert message:", error)
log.error("Failed to revert message", error)
showAlertDialog("Failed to revert message", {
title: "Undo failed",
variant: "error",
})
}
},
})
@@ -503,7 +508,7 @@ export function useCommands(options: UseCommandsOptions) {
category: "System",
keywords: ["/help", "shortcuts", "help"],
action: () => {
console.log("Show help modal (not implemented)")
log.info("Show help modal (not implemented)")
},
})
}
@@ -513,11 +518,11 @@ export function useCommands(options: UseCommandsOptions) {
const result = command.action?.()
if (result instanceof Promise) {
void result.catch((error) => {
console.error("Command execution failed:", error)
log.error("Command execution failed", error)
})
}
} catch (error) {
console.error("Command execution failed:", error)
log.error("Command execution failed", error)
}
}