fix(v0.1.6): Bash tool calls always reported "error" — Rust serde casing#75
Merged
Conversation
… → TS camelCase) The visible symptom from the 0.1.5 user playtest: a green-exit-code Bash command (`ls -la` on an empty dir) showed a red `✕ error` badge on the tool card. The underlying issue: Rust output structs (`ReadOk`, `EditOk`, `BashOk`) serialized fields in snake_case (`exit_code`, `lines_total`, `diff_preview`). The TS wrappers in mac-tools.ts read them in camelCase (`r.exitCode`, `r.linesTotal`, `r.diffPreview`). serde-rs does not auto-convert, so every field came back undefined on the JS side. For BashOk that meant `r.exitCode !== 0` was `undefined !== 0` == true, so `isError` was always set, so every successful Bash call rendered red. For ReadOk/EditOk it silently dropped the line totals and diff previews shown in the chat. Fix: add `#[serde(rename_all = "camelCase")]` on the three response structs. Input structs (BashInput, EditInput, GrepInput) keep `rename_all = "snake_case"` because the JS side intentionally sends snake_case fields (matches the agent's tool schema). Glob and Grep response structs were single-word fields already, no change. Polish carry-over: - ⌘N (new session) / ⌘, (settings) / ⌘/ (about) keyboard shortcuts via new src/lib/keyboard.ts helper - Switching project now clears agent history + chat (was: old conversation persisted with new cwd, confusing) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
User playtest of 0.1.5 found a real bug: Bash command
ls -lasucceeded but showed a red error badge.Root cause: Rust output structs (ReadOk, EditOk, BashOk) serialize snake_case (
exit_code); TS reads camelCase (r.exitCode). undefined != 0 → isError always true → red badge.Fix: add
#[serde(rename_all = "camelCase")]on the 3 response structs.Carries forward: ⌘N/⌘,/⌘/ keyboard shortcuts + switch-project clears chat.
🤖 Generated with Claude Code