Skip to content

Commit 68c3def

Browse files
Kasper JungeRalphify
authored andcommitted
workspace: record reader thread handle inline in _read_agent_stream
Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent b24accf commit 68c3def

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

β€Žworkspace/ralphs/improve-codebase/coverage/_agent.mdβ€Ž

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
# `_agent.py` coverage
22

3-
Valid at: e1ad87a
3+
Valid at: b24accf
44

55
## Recent changes
66

7+
- b24accf β€” inlined the `reader` thread handle in `_read_agent_stream`.
8+
The local served only to call `.start()`; the thread is never joined
9+
explicitly (termination is signalled through the queue's `None`
10+
sentinel produced by `_readline_pump`'s `finally` and through the
11+
daemon flag). Collapsing into the fluent
12+
`threading.Thread(target=_readline_pump, args=(stdout, line_q),
13+
daemon=True).start()` drops an unused binding and matches the
14+
fire-and-forget intent. Python keeps live threads reachable via
15+
`threading._active`, so no GC risk. Side effects preserved: the
16+
reader still closes cleanly on `_close_pipes` (OSError in
17+
`readline`), and the main loop still relies on `line_q.get` for
18+
deadline enforcement. Pinned by the full `tests/test_agent.py`
19+
suite (streaming-path coverage). This is the same alias/handle-drop
20+
shape as e1ad87a / 497c028 / b19625e, specialised to a Thread β€”
21+
thread-return values aren't special, they're just another handle
22+
whose only use was `.start()`.
723
- e1ad87a β€” inlined the `binary = Path(cmd[0]).stem` local in
824
`_supports_stream_json`. The alias was read exactly once on the
925
following line as `binary == CLAUDE_BINARY`. Collapsing to

β€Žworkspace/ralphs/improve-codebase/iterations.mdβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
One line per iteration: `<sha> <summary>`.
44

5+
b24accf refactor: inline `reader` thread handle in `_read_agent_stream` β€” the local served only to call `.start()`; the thread is never joined because termination flows through the queue's None sentinel plus the daemon flag, so the handle had no further role. Collapsing into the fluent `threading.Thread(..., daemon=True).start()` form matches the fire-and-forget intent and drops an unused binding. Python's `threading` module keeps live threads reachable via `threading._active`, so dropping the local reference does not affect thread lifetime β€” verified by the full agent test suite (628 passed). Same alias/handle-drop shape as 2fda4f0 / e1ad87a / 497c028 / b19625e, specialised to a Thread.
6+
57
2fda4f0 refactor: inline `visible` alias in `_LivePanelBase._build_body` β€” the `visible = self._scroll_lines[-_MAX_VISIBLE_SCROLL:]` local was read exactly once, as the iterable of the very next `for line in visible:` loop. Collapsing to `for line in self._scroll_lines[-_MAX_VISIBLE_SCROLL:]:` matches the inline-alias pattern from 497c028 / fc5e1cb / 52e0272 / ce487d3 / e1ad87a. Behavior unchanged β€” the slice still materializes the last `_MAX_VISIBLE_SCROLL` items, and each loop iteration still mutates the Text in-place (`no_wrap` / `overflow`) before appending to `rows`. Pinned by the broad `test_console_emitter.py` suite (peek-visible rendering paths).
68

79
e1ad87a refactor: inline `binary` alias in `_supports_stream_json` β€” the local was assigned to `Path(cmd[0]).stem` and then read exactly once on the next line as `binary == CLAUDE_BINARY`. Collapsing to the chained form `Path(cmd[0]).stem == CLAUDE_BINARY` matches the already-inline sibling check in `_console_emitter.py:_is_claude_command` (`return Path(parts[0]).stem == CLAUDE_BINARY`) and the inline-alias pattern from ce487d3 / 52e0272 / 497c028 / fc5e1cb. Same behavior β€” `_supports_stream_json` still short-circuits on empty `cmd` first, and the final boolean result is unchanged. Pinned by `tests/test_agent.py::test_streaming_mode_used_for_claude` and the broader agent-selection tests.

0 commit comments

Comments
Β (0)