Skip to content

Commit 1ffe9c2

Browse files
Kasper JungeRalphify
authored andcommitted
workspace: record binary alias inline in _supports_stream_json
Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent e1ad87a commit 1ffe9c2

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

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

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

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

55
## Recent changes
66

7+
- e1ad87a — inlined the `binary = Path(cmd[0]).stem` local in
8+
`_supports_stream_json`. The alias was read exactly once on the
9+
following line as `binary == CLAUDE_BINARY`. Collapsing to
10+
`return Path(cmd[0]).stem == CLAUDE_BINARY` matches the already-inline
11+
sibling check in `_console_emitter.py:_is_claude_command`
12+
(`return Path(parts[0]).stem == CLAUDE_BINARY`). Same Phase 4
13+
inline-alias shape as ce487d3 / 52e0272 / 497c028 / fc5e1cb. Empty-cmd
14+
short-circuit (`if not cmd: return False`) preserved so
15+
`Path(cmd[0])` never gets indexed into an empty list. Backlog note
16+
about consolidating `_is_claude_command` and `_supports_stream_json`
17+
across modules is unchanged — still deferred until a third caller
18+
appears.
719
- cf72fd9 — replaced the `parsed = None` sentinel in `_read_agent_stream`
820
with a `try/except/else` block. The old code set `parsed = None` in
921
the JSON-decode-except branch solely so the next line's

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+
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.
6+
57
c5ce11d refactor: inline `reason = state.status.reason` alias in `run_loop`'s `RUN_STOPPED` emit. The local was read exactly once as the `reason=` kwarg to `RunStoppedData(...)` on the next line; collapsing to `reason=state.status.reason` matches the inline-alias pattern from ce487d3 (`text`) / 52e0272 (`msg`) / 497c028 (`agent`) / fc5e1cb (`total_in`). Safe at this call site — the immediately-preceding `if state.status == RunStatus.RUNNING: state.status = RunStatus.COMPLETED` normalizes status to a terminal value (STOPPED / COMPLETED / FAILED), so the `RunStatus.reason` property's "non-terminal raises ValueError" guard cannot fire.
68

79
3823019 refactor: narrow `line = escape_markup(data["line"])` scope past the early-return guard in `_on_agent_output_line` — the local was computed unconditionally inside `_console_lock` but only used on the `_IterationSpinner` branch; the `if not isinstance(target, _IterationSpinner): return` early-return path would have thrown the value away. Moving the binding below the guard preserves exactly the same output (same escape_markup call, same f-string, same add_scroll_line) while skipping the wasted work whenever target is None or an _IterationPanel. Same Phase 4 shape as 134078d (`name_col`), 7730dd4 (`secs`), ef176bf (`line_count`), 59b0e34 (`page`). Pinned by the raw-line handling tests in test_console_emitter.py.

0 commit comments

Comments
 (0)