Implement the following plan: Add Raw Body Toggle & Copy to Details View Context The…
- User
Implement the following plan:
Add Raw Body Toggle & Copy to Details View
Context
The details view currently shows the request body as pretty-printed JSON (when parseable) or raw text. We need to add:
- A toggle to switch between pretty-printed and raw body display
- A keybinding to copy the raw request body to the clipboard
Changes —
/Users/sorrell/src/tools/webhook-tui/main.go1. Add
showRawBodyfield toModelstruct (~line 183)- Add
showRawBody boolfield to track toggle state
2. Update
buildDetailContent()(~line 1117)- When
m.showRawBodyis true, always renderwh.Bodyas-is (no JSON pretty-printing) - When false, keep current behavior (pretty-printed JSON with syntax highlighting)
3. Add keybindings in the
tea.KeyMsghandler (~line 649-769)rkey inStateDetail: ToggleshowRawBody, rebuild content, update viewportykey inStateDetail: Copy raw body to clipboard (usepbcopyon macOS viaexec.Command)- Note:
ris already used inStateRunningfor reconnect, but not inStateDetail, so no conflict
- Note:
4. Update help text in
viewDetail()(~line 1192)- Add
r: raw toggle • y: copy bodyto the help line
5. Update header in
viewDetail()(~line 1169)- Show indicator when raw mode is active (e.g., append "[RAW]" to header)
Verification
- Run the app, receive a webhook with a JSON body
- Open details view — should show pretty-printed JSON (default)
- Press
r— body should switch to raw text, header shows [RAW] - Press
ragain — back to pretty-printed - Press
y— raw body should be in clipboard (verify withpbpaste)
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/sorrell/.REDACTED.jsonl
Assistant
I'll implement this plan. Let me start by reading the relevant parts of the file.
Assistant
Good, I have all the context. Let me implement the changes.
Assistant
Now add the
randykeybindings. I'll add them after the existingrcase block.Assistant
Now update the header in
viewDetail()to show[RAW]indicator:Assistant
Now update the help text:
Assistant
Now let me verify it compiles:
Assistant
Builds cleanly. Here's a summary of the changes:
showRawBodyfield added toModelstruct to track toggle statebuildDetailContent()updated — whenshowRawBodyis true, renders the body as-is without JSON pretty-printing/syntax highlightingrkey inStateDetailtoggles raw body mode and rebuilds the viewport content; inStateRunningit still reconnects the tunnel (no conflict)ykey inStateDetailcopies the raw request body to clipboard viapbcopy- Header shows
[RAW]indicator when raw mode is active - Help text updated with
r: raw toggle • y: copy body