-
Notifications
You must be signed in to change notification settings - Fork 13
fix(ui,process): dashboard agent lifecycle feedback + Windows daemon stop #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lucifer78907
wants to merge
5
commits into
initializ:main
Choose a base branch
from
lucifer78907:fix/forge_bugs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ea6f795
fix(ui): surface stopping state and stop clobbering the agent card
lucifer78907 b732c1f
fix(process): don't treat handle openability as liveness on Windows
lucifer78907 b9f974f
fix(chat): ensure proper cleanup of chat stream on component unmount
lucifer78907 4d950a1
fix(sse): ensure all event types are handled in EventSource listeners
lucifer78907 78c9faa
review(ui): document broadcastStatus aliasing + restore true prior st…
lucifer78907 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| //go:build windows | ||
|
|
||
| package process | ||
|
|
||
| import ( | ||
| "os/exec" | ||
| "syscall" | ||
| "testing" | ||
| ) | ||
|
|
||
| // Windows keeps a terminated process's kernel object alive while any | ||
| // handle to it stays open, so OpenProcess still succeeds against a dead | ||
| // PID. `forge serve stop` holds exactly such a handle (from | ||
| // os.FindProcess) while it polls IsAlive, which made an | ||
| // openability-based check report its own dead child as running until the | ||
| // timeout expired — then fail with "Access is denied" on the second kill. | ||
| // | ||
| // TestIsAlive_ChildAfterExit does not cover this: cmd.Wait() closes Go's | ||
| // handle, releasing the object before the check runs. The handle must be | ||
| // held across the kill to reproduce it. | ||
| func TestIsAlive_FalseWhileHandleHeld(t *testing.T) { | ||
| // ping runs long enough to be observed alive and needs no stdin | ||
| // (timeout/pause both fail when stdin isn't a console). | ||
| cmd := exec.Command("ping", "-n", "30", "127.0.0.1") | ||
| if err := cmd.Start(); err != nil { | ||
| t.Fatalf("starting subprocess: %v", err) | ||
| } | ||
| pid := cmd.Process.Pid | ||
| defer func() { | ||
| _ = cmd.Process.Kill() | ||
| _, _ = cmd.Process.Wait() | ||
| }() | ||
|
|
||
| // Mirror os.FindProcess: an independent handle held across the kill. | ||
| h, err := syscall.OpenProcess(processQueryLimitedInfo|processSynchronize, false, uint32(pid)) | ||
| if err != nil { | ||
| t.Fatalf("OpenProcess: %v", err) | ||
| } | ||
| defer syscall.CloseHandle(h) //nolint:errcheck | ||
|
|
||
| if !IsAlive(pid) { | ||
| t.Fatalf("IsAlive(pid=%d) = false while running, want true", pid) | ||
| } | ||
|
|
||
| if err := cmd.Process.Kill(); err != nil { | ||
| t.Fatalf("Kill: %v", err) | ||
| } | ||
| if _, err := cmd.Process.Wait(); err != nil { | ||
| t.Fatalf("Wait: %v", err) | ||
| } | ||
|
|
||
| // h is still open, so the PID remains openable. IsAlive must not be | ||
| // fooled by that. | ||
| if IsAlive(pid) { | ||
| t.Errorf("IsAlive(pid=%d) = true for a terminated process while a handle is held, want false", pid) | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change requested (document the assumption):
snapshot := *infois a shallow copy. It correctly fixes the bug because the fields mutated between broadcasts (Status/Port/Error) are scalars, so the copy fully decouples them — that is exactly right. The subtlety is that AgentInfo's slice fields (Tools/Channels/Skills) still share the caller's backing arrays, so this only stays correct as long as those slices are reassigned at load and never mutated in place after a broadcast. Please add a one-line comment here recording that assumption, so a future in-place slice mutation doesn't silently reintroduce the aliasing for those fields.