Skip to content

fix: replace noisy console.warn with structured logger in steps.ts#186

Merged
johannesjo merged 2 commits into
johannesjo:mainfrom
xbrxr03:fix/noisy-console-warn-steps
Jun 24, 2026
Merged

fix: replace noisy console.warn with structured logger in steps.ts#186
johannesjo merged 2 commits into
johannesjo:mainfrom
xbrxr03:fix/noisy-console-warn-steps

Conversation

@xbrxr03

@xbrxr03 xbrxr03 commented Jun 22, 2026

Copy link
Copy Markdown

The step watcher was logging every send and every file change at console.warn level — that's debug info, not a warning. In a normal session with multiple agents running, this spams the console with hundreds of entries that make real warnings impossible to spot.

Switched all logging in steps.ts to the structured logger that the rest of the main process already uses:

  • Routine events (step sends, watch events) → info level
  • Actual failures (write errors, watcher errors) → warn level
  • All entries use structured context objects instead of string concatenation

Found during quality audit (#157, finding 41).

@johannesjo

Copy link
Copy Markdown
Owner

Review — structured logger migration in steps.ts

Clean, well-targeted change. The level mapping is the right fix: info is suppressed under the prod warn floor, so the console spam disappears in real sessions while staying visible in dev, and the structured context objects are a clear improvement over string concatenation. Verified the logger API (info/warn/errMessage) and the ../log.js ESM import path against the call sites — all correct.

One gap and two minor nits:

Important — one console.error is left behind (contradicts "Switched all logging").
readStepsFile at electron/ipc/steps.ts:80 still does:

console.error('[steps] Failed to read steps file:', e);

This is the one genuine error path in the file (corrupt/unreadable steps.json, non-ENOENT), and it's exactly what log.ts's error(category, msg, err, ctx) exists for — it also captures the stack. Suggest:

import { error as logError, info as logInfo, warn as logWarn, errMessage } from '../log.js';
// ...
logError('steps', 'failed to read steps file', e);

Minor — watch event logs before the filename filter.
At steps.ts:160, the logInfo('steps', 'watch event', …) fires for every file change in .claude/, not just steps.json (the filename \!== 'steps.json' early-return is on the next line). It's the highest-frequency log here, so debug reads as more honest than info — relevant if a user lowers the floor to info via the renderer's level_min, which would re-introduce spam one level down. No-op under the current prod/dev floors, so purely a level-choice nuance.

Minor — stack traces dropped for watch-setup failures.
errMessage(err) keeps only err.message. For failed to watch worktree root / failed to watch steps dir (steps.ts:194,220), the failure silently disables live step updates for that task. The old console.warn(msg, err) printed the full Error incl. stack; consider error level here so the logger captures the stack for the cases that actually break the feature. Fine to keep as warn if these are treated as recoverable.

Otherwise good to merge.

🤖 Automated review via Claude Code

AJH763 added 2 commits June 23, 2026 15:01
The step watcher was logging every send and watch event at warn level
using console.warn — that's debug info, not a warning. Switched all
logging to the structured logger (info for routine events, warn for
actual failures) so the console isn't spammed during normal operation.

Found during quality audit (johannesjo#157, finding 41).
…ug for watch events

- Replace leftover console.error in readStepsFile with logError (captures full stack)
- Downgrade watch-event log from info to debug (fires per file change, not just steps.json)
- Promote watcher error handlers to logError so stack traces are preserved
  for setup failures that silently disable live step updates
@xbrxr03 xbrxr03 force-pushed the fix/noisy-console-warn-steps branch from d2980ba to 093e7fc Compare June 23, 2026 19:03
@xbrxr03

xbrxr03 commented Jun 23, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough review! Pushed a follow-up commit addressing all three points:

  1. Remaining `console.error` — replaced with `logError' in `readStepsFile`. It now captures the full stack trace through the structured logger instead of just printing to stderr.

  2. Watch-event `info` → `debug` — the `onChange` callback now logs at `debug` level, so it won't fire at all under the default `warn` floor. This is the highest-frequency log site in the file, so the level choice matters.

  3. Watcher setup errors → `error` level — the three watcher error handlers (`parentWatcher.on('error', …)`, the `fs.watch` catch, and `attachStepsDirWatcher`'s catch/error) now use `logError` instead of `logWarn`. These failures silently disable live step updates, so the stack trace capture matters. The `errMessage()` wrapper is gone — `logError` already serialises and clips stacks internally.

All 1420 tests pass, typecheck + lint clean.

@johannesjo

Copy link
Copy Markdown
Owner

Thank you very much! <3

@johannesjo johannesjo merged commit 85f78bc into johannesjo:main Jun 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants