Skip to content

Commit 1161e2d

Browse files
Kasper JungeRalphify
authored andcommitted
workspace: record remaining alias inline in _read_agent_stream
Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 66d6c60 commit 1161e2d

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

workspace/ralphs/improve-codebase/coverage/_agent.md

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

3-
Valid at: b24accf
3+
Valid at: 66d6c60
44

55
## Recent changes
66

7+
- 66d6c60 — inlined the `remaining = deadline - time.monotonic()` local
8+
in `_read_agent_stream`'s per-iteration timeout calc. The alias was
9+
read exactly once on the next line as `max(remaining, 0)`; collapsing
10+
to `max(deadline - time.monotonic(), 0)` matches the inline-alias
11+
style from e1ad87a / 497c028 / 52e0272 / ce487d3. The adjacent
12+
comment was updated ("max(remaining, 0)" → "clamp to 0") since the
13+
name no longer exists. Behavior preserved — the clamped timeout
14+
still reaches `line_q.get(timeout=...)`, so the non-blocking drain
15+
on an already-expired deadline still fires and deadline enforcement
16+
is unchanged. Pinned by the streaming-path agent tests. No other
17+
`remaining` locals remain in the module (grep confirmed).
718
- b24accf — inlined the `reader` thread handle in `_read_agent_stream`.
819
The local served only to call `.start()`; the thread is never joined
920
explicitly (termination is signalled through the queue's `None`

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+
66d6c60 refactor: inline `remaining` alias in `_read_agent_stream` timeout calc — the `remaining = deadline - time.monotonic()` local served a single use on the very next line as `max(remaining, 0)`. Collapsing to `max(deadline - time.monotonic(), 0)` matches the inline-alias pattern from e1ad87a (`binary`), 497c028 (`agent`), fc5e1cb (`total_in`), 52e0272 (`msg`), and ce487d3 (`text`). The adjacent comment was updated to refer to "clamp to 0" since `remaining` no longer exists. Behavior preserved — the same clamped value reaches `line_q.get(timeout=...)` on every iteration of the read loop, so deadline enforcement and the non-blocking drain on an already-expired deadline both behave identically. Pinned by the streaming-path tests in `tests/test_agent.py`.
6+
57
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.
68

79
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).

0 commit comments

Comments
 (0)