feat: typed command errors + structured logging - #5
Conversation
CommandError now serializes as {type, message} JSON across the Tauri
bridge — frontend can branch on error kind rather than parsing strings.
tauri-plugin-log wires Rust log:: calls to ~/Library/Logs/adhd-ranch/.
ui_bridge logs mutating ops at info (focus/task/proposal lifecycle) and
all errors at error level. Frontend mutation APIs log failures via
console.error with the typed error object.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds structured, serializable command errors and integrates Tauri logging; refactors Tauri command handlers to return ChangesStructured Error Handling and Logging Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 8/10 reviews remaining, refill in 9 minutes and 8 seconds. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src-tauri/src/ui_bridge/mod.rs`:
- Line 49: The current inspect_err closure in the create_focus call logs the raw
user-provided title (inspect_err(|e| log::error!("create_focus({title:?}):
{e}"))), which may persist sensitive content; change the inspector to avoid
including the raw title—log only the operation context and error (e.g.,
"create_focus error" plus the error), or if you need reference to the input
include a non-sensitive surrogate such as a fixed "[REDACTED]" tag, a
length/hash indicator, or truncated/normalized form instead of the full title in
the inspect_err closure for create_focus.
In `@src/api/tauriProposalReader.ts`:
- Around line 3-4: Import ordering of the two type imports is incorrect and
fails Biome organizeImports; reorder the type imports so they match the
formatter's expected alphabetical or configured order by swapping the two import
lines referencing the Proposal and CommandError types (types Proposal and
CommandError in tauriProposalReader.ts) so the imports follow the project’s
import sorting rules.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 84ea79fc-49a6-4fa8-9fd2-f8af1c3c725c
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
crates/commands/src/error.rssrc-tauri/Cargo.tomlsrc-tauri/src/app/mod.rssrc-tauri/src/ui_bridge/mod.rssrc/api/focusWriter.tssrc/api/tauriProposalReader.tssrc/types/error.ts
| }) | ||
| .map_err(|e| e.to_string()) | ||
| .inspect(|f| log::info!("focus created: {}", f.id)) | ||
| .inspect_err(|e| log::error!("create_focus({title:?}): {e}")) |
There was a problem hiding this comment.
Avoid persisting raw focus titles in error logs.
Line 49 logs user-provided title verbatim into persistent logs, which can capture sensitive personal text. Log operation context and error without raw content.
Proposed diff
- .inspect_err(|e| log::error!("create_focus({title:?}): {e}"))
+ .inspect_err(|e| log::error!("create_focus failed: {e}"))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .inspect_err(|e| log::error!("create_focus({title:?}): {e}")) | |
| .inspect_err(|e| log::error!("create_focus failed: {e}")) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src-tauri/src/ui_bridge/mod.rs` at line 49, The current inspect_err closure
in the create_focus call logs the raw user-provided title (inspect_err(|e|
log::error!("create_focus({title:?}): {e}"))), which may persist sensitive
content; change the inspector to avoid including the raw title—log only the
operation context and error (e.g., "create_focus error" plus the error), or if
you need reference to the input include a non-sensitive surrogate such as a
fixed "[REDACTED]" tag, a length/hash indicator, or truncated/normalized form
instead of the full title in the inspect_err closure for create_focus.
- Log DisplayConfigState lock failure instead of silently ignoring (#3) - set_debug_overlay: only emit event when lock succeeds, not on failure (#4) - SettingsWindow: wrap onToggleDevtools in arrow to explicitly drop the boolean arg from ToggleRow onChange (#5) - Update 032 issue spec to match implemented tray/display behavior (#1)
* [032] Preferences window: settings UI, tray simplification, debug overlay control - Add on-demand Preferences window (Cmd-, / tray → Settings…) - Sections: General (caps), Widget, Displays, Alerts, Debug - Auto-sizes to content via ResizeObserver + Tauri setSize - Reopens cleanly after close: destroys stale label, creates fresh window - Simplify tray: replace Settings submenu with single Settings… item - Add Tauri commands: get/update settings, get monitors, get/set debug overlay, toggle/query devtools - Debug overlay off by default; toggled via Settings > Debug > Debug Overlay using backend app.emit for reliable cross-window event delivery - DebugOverlayState managed in app; devtools toggle uses is_devtools_open * fix: address CR comments on 032 preferences window - Log DisplayConfigState lock failure instead of silently ignoring (#3) - set_debug_overlay: only emit event when lock succeeds, not on failure (#4) - SettingsWindow: wrap onToggleDevtools in arrow to explicitly drop the boolean arg from ToggleRow onChange (#5) - Update 032 issue spec to match implemented tray/display behavior (#1)
Summary
CommandErrornow derivesserde::Serializewith#[serde(tag = "type", content = "message")]— errors cross the Tauri bridge as{type: "not_found", message: "..."}instead of opaque stringstauri-plugin-logwired in — Rustlog::calls land in~/Library/Logs/adhd-ranch/(readable in Console.app or vialog stream --predicate 'process == "adhd-ranch"')ui_bridgereturnsResult<T, CommandError>on all commands; mutating ops logged atinfo, errors aterrorCommandErrordiscriminated union type insrc/types/error.ts; mutation APIs log failures viaconsole.errorwith structured error objectTest plan
cargo test --workspacepasses (111 tests)tsc --noEmitclean~/Library/Logs/adhd-ranch/has log file withfocus created:entryalready_existserrorSummary by CodeRabbit
New Features
User-facing Improvements
Chores