Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
==========================================
- Coverage 74.37% 72.40% -1.97%
==========================================
Files 7 8 +1
Lines 804 859 +55
==========================================
+ Hits 598 622 +24
- Misses 175 204 +29
- Partials 31 33 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a "Break" functionality to the struct explorer, which provides debugging breakpoint capabilities by starting an HTTP server that blocks execution until manually resumed through a web interface.
- Adds
Break()functions for temporary runtime inspection with automatic browser opening - Enhances
Dump()method to accept optional filename parameter - Implements resume functionality through web UI button and server shutdown mechanism
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| service.go | Core implementation of Break/resume functionality and Dump enhancement |
| script.js | JavaScript resume function for web UI interaction |
| open.go | Cross-platform browser opening utility |
| index_tmpl.html | Resume button UI element |
| index_data.go | Data structure to track breaking state |
| index_builder.go | Builder field for breaking state |
| explorer.go | Integration of breaking state into index data |
| examples/break/ | Example usage of Break functionality |
| README.md | Documentation updates for new features |
| CHANGES.md | Version changelog entry |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| s.httpServer = server | ||
| open(fmt.Sprintf("http://localhost:%d", port)) | ||
| // this blocks until server is closed by resume operation. | ||
| server.ListenAndServe() |
There was a problem hiding this comment.
The return value of ListenAndServe() should be checked. If the server fails to start, the error will be ignored and the function will return silently, potentially leaving the caller in an unexpected state.
| server.ListenAndServe() | |
| if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed { | |
| slog.Error("server failed", "err", err) | |
| } |
| Handler: serveMux, | ||
| } | ||
| s.httpServer = server | ||
| open(fmt.Sprintf("http://localhost:%d", port)) |
There was a problem hiding this comment.
The error return value from open() is ignored. If opening the browser fails, the user won't be notified, which could be confusing since they might expect a browser window to appear.
| open(fmt.Sprintf("http://localhost:%d", port)) | |
| if err := open(fmt.Sprintf("http://localhost:%d", port)); err != nil { | |
| slog.Error("failed to open browser", "err", err) | |
| } |
| case "linux" == runtime.GOOS: | ||
| return exec.Command("xdg-open", uri).Start() | ||
| default: | ||
| return fmt.Errorf("unable to open uri:%v on:%v", uri, runtime.GOOS) |
There was a problem hiding this comment.
Missing space in error message format string.
| return fmt.Errorf("unable to open uri:%v on:%v", uri, runtime.GOOS) | |
| return fmt.Errorf("unable to open uri: %v on: %v", uri, runtime.GOOS) |
| function resume() { | ||
| const xhr = new XMLHttpRequest(); | ||
| xhr.open("POST", window.location.href); | ||
| xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8") |
There was a problem hiding this comment.
Missing semicolon at end of statement. This is inconsistent with the coding style used elsewhere in the file.
| xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8") | |
| xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); |
No description provided.