refactor: remove command output rendering
This commit is contained in:
@@ -40,9 +40,6 @@ Optional flags:
|
||||
- `--progress-silent/--no-progress-silent` (default silent)
|
||||
- `--final-notify/--no-final-notify` (default notify via new message)
|
||||
- `--ignore-backlog/--process-backlog` (default ignore pending updates)
|
||||
- `--codex-io-mode [threads|selectors|asyncio]` (default `threads`)
|
||||
- `--codex-command-timeout FLOAT` (default: disabled, debug defaults to 60s)
|
||||
- `--codex-no-child-timeout FLOAT` (default `15.0`, set `0` to disable)
|
||||
- `--workdir PATH` (override `codex_workspace`)
|
||||
- `--model NAME` (pass through to `codex exec`)
|
||||
|
||||
|
||||
@@ -178,7 +178,6 @@ class CodexExecRunner:
|
||||
prompt: str,
|
||||
session_id: Optional[str],
|
||||
on_event: Optional[Callable[[Dict[str, Any]], None]] = None,
|
||||
show_output: bool = False,
|
||||
) -> Tuple[str, str, bool]:
|
||||
"""
|
||||
Returns (session_id, final_agent_message_text)
|
||||
@@ -235,7 +234,7 @@ class CodexExecRunner:
|
||||
evt = json.loads(line)
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
for out in render_event_cli(evt, cli_state, show_output=show_output):
|
||||
for out in render_event_cli(evt, cli_state):
|
||||
log(f"[codex] {out}")
|
||||
if on_event is not None:
|
||||
try:
|
||||
@@ -272,16 +271,15 @@ class CodexExecRunner:
|
||||
prompt: str,
|
||||
session_id: Optional[str],
|
||||
on_event: Optional[Callable[[Dict[str, Any]], None]] = None,
|
||||
show_output: bool = False,
|
||||
) -> Tuple[str, str, bool]:
|
||||
"""
|
||||
If resuming, serialize per-session.
|
||||
"""
|
||||
if not session_id:
|
||||
return self.run(prompt, session_id=None, on_event=on_event, show_output=show_output)
|
||||
return self.run(prompt, session_id=None, on_event=on_event)
|
||||
lock = self._lock_for(session_id)
|
||||
with lock:
|
||||
return self.run(prompt, session_id=session_id, on_event=on_event, show_output=show_output)
|
||||
return self.run(prompt, session_id=session_id, on_event=on_event)
|
||||
|
||||
|
||||
# -------------------- Telegram loop --------------------
|
||||
@@ -309,11 +307,6 @@ def run(
|
||||
"--ignore-backlog/--process-backlog",
|
||||
help="Skip pending Telegram updates that arrived before startup.",
|
||||
),
|
||||
verbose: bool = typer.Option(
|
||||
False,
|
||||
"--verbose/--quiet",
|
||||
help="Include command output in CLI logs.",
|
||||
),
|
||||
log_file: Optional[str] = typer.Option(
|
||||
"exec_bridge.log",
|
||||
"--log-file",
|
||||
@@ -478,7 +471,6 @@ def run(
|
||||
text,
|
||||
resume_session,
|
||||
on_event=on_event,
|
||||
show_output=verbose,
|
||||
)
|
||||
except Exception as e:
|
||||
_stop_background()
|
||||
|
||||
@@ -112,15 +112,6 @@ def _with_id(item_id: Optional[int], line: str) -> str:
|
||||
return f"[?] {line}"
|
||||
|
||||
|
||||
def _truncate_output(text: str, max_lines: int = 20, max_chars: int = 4000) -> str:
|
||||
if len(text) > max_chars:
|
||||
text = text[-max_chars:]
|
||||
lines = text.splitlines()
|
||||
if len(lines) > max_lines:
|
||||
lines = ["..."] + lines[-max_lines:]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def _format_item_action_line(etype: str, item_id: Optional[int], item: dict[str, Any]) -> str | None:
|
||||
itype = item["type"]
|
||||
if itype == "command_execution":
|
||||
@@ -207,8 +198,6 @@ def _complete_action(state: ExecRenderState, item_id: Optional[int], line: str)
|
||||
def render_event_cli(
|
||||
event: dict[str, Any],
|
||||
state: ExecRenderState,
|
||||
*,
|
||||
show_output: bool = False,
|
||||
) -> list[str]:
|
||||
etype = event["type"]
|
||||
lines: list[str] = []
|
||||
@@ -244,10 +233,6 @@ def render_event_cli(
|
||||
action_line = _format_item_action_line(etype, item_num, item)
|
||||
if action_line is not None:
|
||||
lines.append(action_line)
|
||||
if show_output and itype == "command_execution" and etype == "item.completed":
|
||||
output = _truncate_output(item["aggregated_output"])
|
||||
if output:
|
||||
lines.extend(indent(output, " ").splitlines())
|
||||
elif etype == "item.completed":
|
||||
completed_line = _format_item_completed_line(item_num, item)
|
||||
if completed_line is not None:
|
||||
|
||||
Reference in New Issue
Block a user