Repository navigation
fix: tasks, event streams and child processes (review P1-2) - #201
Merged
Merged
Conversation
- a step waiting for the user can be taken over; the question stays, answered under takeover or after handing back (daemon, page, demo) - nothing is recorded after a task's done (a step under way is stopped first); a follower that lagged catches up from the log instead of missing done and staying open - the page: a stream the browser closed for good is followed again or the task marked stopped; marks drawn once per step; unknown states shown as is - process groups: watched during the grace, no SIGKILL once gone; task run waits for what its command left before exiting; timed commands killed on drop (doctor, ffmpeg) - the MJPEG relay ends when the daemon switches devices; Viewer::drop on the LocalSet - HEVC to H.264: a closed ffmpeg input is a failure; repeated failures move to the next encoder - task run --url: stop() times out; silent or endless event streams end - one daemon per socket (flock), the socket private from creation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors
force-pushed
the
fix/p1-tasks-streams
branch
from
November 25, 2026 14:47
c7d4c85 to
eefe2b0
Compare
13 tasks done
…eload, process groups) - A task's end stops every step still under way (`in_flight`), not only the latest: a tool call asking to leave the task's scope and its question are two. The page also closes steps left open when `done` arrives (older daemons). - Steps saved before a reload keep their gesture, so the replayed stream doesn't draw their marks again. - `stop_and_wait` drops a group as soon as it is gone, instead of keeping it for the SIGKILL after the grace another group took. - `task run` looks for what the command left right after reaping it and stops it at once, alongside telling the daemon, instead of after two calls that may take seconds. - `single_instance` reports a flock error other than contention instead of waiting 15 s and calling it another daemon. - Approving a step while taken over says the AI goes on once handed back. - The SSE test installs the rustls provider itself (it depended on test order). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Derrors
force-pushed
the
fix/p1-tasks-streams
branch
from
November 25, 2026 16:25
65dc1e2 to
817eaa0
Compare
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.
What and why
P1, second batch, from the full review of
mainafter #195: tasks, event streams and child processes.Takeover while a step waits for the user (
Task::control):waitingrefusedtakeover, so the user had to answer before looking or changing anything. Now:waiting.The page offers "Take over" while waiting and "Review" while in control with a question open. The demo mode follows the same rules.
Nothing after
done: events kept coming after a task ended (a waiting question woken up, a request finishing). Now:stoppedbeforedone, andemitdrops anything later;Laggedcould missdone, and the broadcast never closes, so the connection stayed open for good;task_streamnow catches up from the task's log and subscribes again.The page's task stream (
tasks.js):taskStatusgives one it doesn't know a plain label.Process groups:
procgroup::stopsent SIGKILL blindly 3 s after SIGTERM, possibly to a reused group number; now it looks every 100 ms and leaves a group that is gone alone;task runexited right after its command, taking the delayed SIGKILL with it, so what ignored SIGTERM stayed; it nowstop_and_waits any group members left;doctor's and ffmpeg's timed commands nowkill_on_drop.Streams:
controlled_changes_from);Viewer::dropusesspawn_local: its task outlived the LocalSet and could close HID again aftershutdown;Closedffmpeg input counts as a failure (it restarted for ever). Repeated failures without frames move to the next encoder, as MJPEG does. Not when ffmpeg only stands in for the built-in encoder: its failure isn't that encoder's.task run --url:stop()times out after 10 s; an event stream ends after 60 s of silence (the viewer pings every 15 s) or an event over 1 MB.One daemon per socket:
ctl.lockbeside the socket is held withflock; a second daemon waits up to 15 s for one that is stopping, and bails at once if one answers;chmod;Tests
1. Unit tests
cargo test --workspace --all-features --locked: 584 passed; clippy-D warnings;cargo fmt --checkfor all 11 packages;node --test tests/viewer/*.test.mjs: 40 passed;tests/check_regression_cases.py: 0 missingthe_user_can_take_over_while_a_step_waits_for_them,nothing_follows_done,a_follower_that_fell_behind_catches_up_and_ends(fails with the oldLaggedarm),a_switch_to_another_device_ends_the_stream,a_group_is_seen_until_it_is_gone,an_event_without_end_ends_the_stream,only_one_daemon_holds_a_socket;a step waiting for the user can be answered after taking over,a step mark is drawn once however often the stream replays it,an unknown task state is shown as it is and does not replace a known one,a stream the browser gave up on is followed again if the task is still there, else marked stoppedsummary.test.mjs's harness getstaskStatus)2. Real-device regression
tests/device/run.pyon the iPhone: 16 calls, 0 failed3. Regression cases
4. Real-device proof
task_confirmwaiting; through the viewer's API: takeover, a tap by the user, handback, back towaiting; takeover again, approve, and the task's request got "approved" while the state stayedtakeover; handback,runningtask run -- sh -c 'trap "" TERM; sleep 301 & exit 0': ended in 3.03 s, and nosleep 301was left/streamthrough the viewer, then the iPhone selected: the stream ended 0.17 s laterctl.sockandctl.lockare 0600; a secondiphone-control daemonexits with "A daemon is already running"task run --urlagainst an unresponsive viewer; macOSChecklist
🤖 Generated with Claude Code