Normalize tool calls for mobile sync: apply_patch as paired CodexPatch diffs - #12
Open
bra1nDump wants to merge 4 commits into
Open
Normalize tool calls for mobile sync: apply_patch as paired CodexPatch diffs#12bra1nDump wants to merge 4 commits into
bra1nDump wants to merge 4 commits into
Conversation
6 tasks
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.
Context for reviewers new to this area
Happy Agent syncs its sessions to the Happy mobile app (
slopus/happy,packages/happy-app) as encrypted messages. The mobile app renders tool calls keyed by tool name, with purpose-built views for a fixed set of names (Edit,CodexPatch,Bash, …). Anything it does not recognize falls back to a generic card.The principle this PR establishes, recorded in
sources/happy/LEARNINGS.md: normalize on the producer side. Happy Agent translates its internal tool calls into the shapes mobile already renders well, so mobile clients never need to parse provider-specific formats (like Codex'sapply_patchgrammar) and older app builds keep working without updates.Where things live:
packages/happy-agent-modules/sources/happy/— the mobile sync bridge: session client, message mapping, pairing.sources/happy/mapHappyMessages.ts— maps internal session events to mobile wire messages.sources/happy/normalizeHappyToolCall.ts(new) — per-tool translation into mobile's renderable shapes.What changed, commit by commit
2b8c2147— Improve Happy tool sync semantics. Tool-result events carry the actual result and error flag to mobile instead ofcontent: null(the counterpart optional fields exist in the app's schema; both sides treat them as optional, so old ↔ new combinations keep working).dccf4f72— Normalizeapply_patchfor Happy mobile. Codexapply_patchcalls are parsed inside Happy Agent and sent as mobile's establishedCodexPatch { changes }payload.4baf45e2— Normalize Happy tools for mobile wire. Extracts the translation intonormalizeHappyToolCall.tsand generalizes it beyond patches, with its own test suite.a613ca73— Render Codex patches as paired mobile diffs. Update hunks go out asmodify: { old_content, new_content }rather than a raw unified diff string. Mobile routes that shape through the same paired, intra-line-highlighted diff renderer it uses for ClaudeEdit; a raw patch string would send it down a simpler prefix-colored fallback.Compatibility
CodexPatch { changes },modify { old_content, new_content }) are ones released mobile apps already render — that is the point of producer-side normalization.How to test
272 tests, all passing. Normalization coverage is in
tests/happy/normalizeHappyToolCall.test.tsandtests/happy/mapHappyMessages.test.ts.Related work
Consumer-side counterpart in the mobile app: slopus/happy#1731 — renders all edit tools as expanded inline diff ribbons, keeps agent questions inline, and documents the tool-rendering registry. That PR's
CodexPatchViewrenders exactly thechangesshapes this branch produces.