You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recreated on the rewritten main after #1099 was auto-closed during repository maintenance. This carries the same reviewed change set on the new history.
Summary
prevent logger initialization from crashing the CLI when the current chat directory cannot be created
keep file logging best-effort while preserving the existing development and production destinations
add regression coverage for both destinations and the unavailable-chat-directory path
full CLI test command: 2,111 passed; existing checkout/environment failures remain in unrelated Infisical, read-only config, and missing release-dependency tests
Good instinct and clean execution. Extracting resolveLogTarget as a pure, injectable function (cli/src/utils/logger.ts) makes the dev/production branching testable without touching the filesystem, and wrapping both directory resolution and setLogPath in try/catch in trySetLogPath correctly turns a hard crash into best-effort logging, which matches the intent of #783.
The three logger.test.ts cases cover the two normal destinations plus the failure path, and the assertions (currentChatDirCalls stays 0 in dev, target is undefined when getCurrentChatDir throws) are meaningful rather than tautological.
A couple of things worth double-checking before porting:
Confirm CHAT_LOG_FILENAME is already exported from logger.ts (not shown as changed in this diff) since the test imports it directly.
Swallowing the error silently in trySetLogPath means there's no signal at all (not even a stderr warning) that file logging failed — worth considering whether a single best-effort console.error on the caught error would help debugging without reintroducing the crash risk. Not blocking, but a reasonable follow-up.
Small, in-scope, focused change with regression coverage — good candidate for porting as-is.
Confirmed CHAT_LOG_FILENAME is already exported (export const CHAT_LOG_FILENAME = 'log.jsonl'). I kept the startup fallback silent intentionally rather than adding console.error: stderr output during startup can corrupt the interactive terminal UI, while file logging is explicitly best-effort. Added that rationale to the catch-path comment. Logger regression tests: 3 passed, 0 failed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #783
Validation
Prior validation before the history rewrite:
logger.test.ts: 3 passedgit diff --check: passed