Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a copy-to-clipboard feature for the diagnostics viewer, allowing users to press 'c' to copy the currently displayed file with automatic JSON pretty-formatting for request/response data.
Changes:
- Added tracking of current filename and part (request/responses) in FileViewer
- Added 'c' keyboard binding to copy current file content with JSON formatting
| try: | ||
| responses = [json.loads(line) for line in lines[1:]] | ||
| if len(responses) == 1: | ||
| content = json.dumps(responses[0], indent=2) | ||
| else: | ||
| content = json.dumps(responses, indent=2) | ||
| except json.JSONDecodeError: |
There was a problem hiding this comment.
This list comprehension will fail if any response line has invalid JSON, causing the entire operation to fall back to copying raw text. This is inconsistent with _show_jsonl (lines 344-349) which parses responses individually and skips malformed lines. Consider using a similar approach: iterate through lines[1:] with individual try-except blocks to collect only valid responses, matching the viewing behavior.
| try: | |
| responses = [json.loads(line) for line in lines[1:]] | |
| if len(responses) == 1: | |
| content = json.dumps(responses[0], indent=2) | |
| else: | |
| content = json.dumps(responses, indent=2) | |
| except json.JSONDecodeError: | |
| responses = [] | |
| for line in lines[1:]: | |
| try: | |
| responses.append(json.loads(line)) | |
| except json.JSONDecodeError: | |
| # Skip malformed JSON lines to match _show_jsonl behavior | |
| continue | |
| if responses: | |
| if len(responses) == 1: | |
| content = json.dumps(responses[0], indent=2) | |
| else: | |
| content = json.dumps(responses, indent=2) | |
| else: |
| try: | ||
| data = json.loads(content) | ||
| content = json.dumps(data, indent=2) | ||
| except json.JSONDecodeError: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| except json.JSONDecodeError: | |
| except json.JSONDecodeError: | |
| # If content is not valid JSON, fall back to copying it as-is. |
…ntext * 'main' of github.com:block/goose: feat: add onFallbackRequest handler to McpAppRenderer (#7208) feat: add streaming support for Claude Code CLI provider (#6833) fix: The detected filetype is PLAIN_TEXT, but the provided filetype was HTML (#6885) Add prompts (#7212) Add testing instructions for speech to text (#7185) Diagnostic files copying (#7209) fix: allow concurrent tool execution within the same MCP extension (#7202) fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143) Filter Apps page to only show standalone Goose Apps (#6811) opt: use static for Regex (#7205) nit: show dir in title, and less... jank (#7138) feat(gemini-cli): use stream-json output and re-use session (#7118) chore(deps): bump qs from 6.14.1 to 6.14.2 in /documentation (#7191) Switch jsonwebtoken to use aws-lc-rs (already used by rustls) (#7189) chore(deps): bump qs from 6.14.1 to 6.14.2 in /evals/open-model-gym/mcp-harness (#7184) Add SLSA build provenance attestations to release workflows (#7097) fix save and run recipe not working (#7186) Upgraded npm packages for latest security updates (#7183) docs: reasoning effort levels for Codex provider (#6798)
* origin/main: (42 commits) fix: use dynamic port for Tetrate auth callback server (#7228) docs: removing LLM Usage admonitions (#7227) feat(otel): respect standard OTel env vars for exporter selection (#7144) fix: fork session (#7219) Bump version numbers for 1.24.0 release (#7214) Move platform extensions into their own folder (#7210) fix: ignore deprecated skills extension (#7139) Add a goosed over HTTP integration test, and test the developer tool PATH (#7178) feat: add onFallbackRequest handler to McpAppRenderer (#7208) feat: add streaming support for Claude Code CLI provider (#6833) fix: The detected filetype is PLAIN_TEXT, but the provided filetype was HTML (#6885) Add prompts (#7212) Add testing instructions for speech to text (#7185) Diagnostic files copying (#7209) fix: allow concurrent tool execution within the same MCP extension (#7202) fix: handle missing arguments in MCP tool calls to prevent GUI crash (#7143) Filter Apps page to only show standalone Goose Apps (#6811) opt: use static for Regex (#7205) nit: show dir in title, and less... jank (#7138) feat(gemini-cli): use stream-json output and re-use session (#7118) ...
Summary
Hitting c now copies the current file - prettifies json for response/requests