diff --git a/codex_telegram_bridge/src/codex_telegram_bridge/exec_render.py b/codex_telegram_bridge/src/codex_telegram_bridge/exec_render.py index 07bea7e..b8449f8 100644 --- a/codex_telegram_bridge/src/codex_telegram_bridge/exec_render.py +++ b/codex_telegram_bridge/src/codex_telegram_bridge/exec_render.py @@ -133,7 +133,6 @@ def _maybe_parse_json(text: str) -> Optional[Any]: @dataclass class ExecRenderState: - items: dict[str, dict[str, Any]] = field(default_factory=dict) recent_actions: deque[str] = field(default_factory=lambda: deque(maxlen=5)) current_action: Optional[str] = None current_action_id: Optional[int] = None @@ -145,7 +144,6 @@ class ExecRenderState: def _record_item(state: ExecRenderState, item: dict[str, Any]) -> None: item_id = item.get("id") if isinstance(item_id, (int, str)): - state.items[str(item_id)] = item numeric_id = _extract_numeric_id(item_id) if numeric_id is not None: state.last_turn = numeric_id @@ -186,7 +184,6 @@ def render_event_cli( event: dict[str, Any], state: ExecRenderState, *, - show_reasoning: bool = False, show_output: bool = False, ) -> list[str]: etype = event.get("type") @@ -225,11 +222,6 @@ def render_event_cli( lines.append("assistant:") lines.extend(indent(text, " ").splitlines() if text else [" (empty)"]) - elif itype == "reasoning" and show_reasoning: - reasoning = _format_reasoning(item.get("text", "")) - if reasoning: - lines.append(reasoning) - elif itype == "command_execution": command = _format_command(item.get("command", "")) if etype == "item.started": diff --git a/codex_telegram_bridge/src/codex_telegram_bridge/rendering.py b/codex_telegram_bridge/src/codex_telegram_bridge/rendering.py index ad4011c..95f0b92 100644 --- a/codex_telegram_bridge/src/codex_telegram_bridge/rendering.py +++ b/codex_telegram_bridge/src/codex_telegram_bridge/rendering.py @@ -6,9 +6,6 @@ from typing import Any, Dict, List, Tuple from markdown_it import MarkdownIt from sulguk import transform_html -from .constants import DEFAULT_CHUNK_LEN - - def render_markdown(md: str) -> Tuple[str, List[Dict[str, Any]]]: html = MarkdownIt("commonmark", {"html": False}).render(md or "") rendered = transform_html(html) @@ -25,41 +22,6 @@ def render_markdown(md: str) -> Tuple[str, List[Dict[str, Any]]]: return text, entities -def chunk_text(text: str, limit: int = DEFAULT_CHUNK_LEN) -> List[str]: - """ - Telegram hard limit is 4096 chars. Chunk at newlines when possible. - """ - text = text or "" - if len(text) <= limit: - return [text] - - out: List[str] = [] - buf: List[str] = [] - size = 0 - - for line in text.splitlines(keepends=True): - if len(line) > limit: - # flush current buffer - if buf: - out.append("".join(buf)) - buf, size = [], 0 - # hard-split this long line - for i in range(0, len(line), limit): - out.append(line[i : i + limit]) - continue - - if size + len(line) > limit: - out.append("".join(buf)) - buf, size = [line], len(line) - else: - buf.append(line) - size += len(line) - - if buf: - out.append("".join(buf)) - return out - - def _chunk_text_with_indices(text: str, limit: int) -> List[Tuple[str, int, int]]: text = text or "" if len(text) <= limit: diff --git a/codex_telegram_bridge/src/codex_telegram_bridge/telegram_client.py b/codex_telegram_bridge/src/codex_telegram_bridge/telegram_client.py index 0867b1c..5c6e393 100644 --- a/codex_telegram_bridge/src/codex_telegram_bridge/telegram_client.py +++ b/codex_telegram_bridge/src/codex_telegram_bridge/telegram_client.py @@ -6,7 +6,7 @@ import urllib.request from typing import Any, Dict, List, Optional from .constants import DEFAULT_CHUNK_LEN, TELEGRAM_HARD_LIMIT -from .rendering import chunk_text, render_markdown, _chunk_text_with_indices, _slice_entities +from .rendering import render_markdown, _chunk_text_with_indices, _slice_entities class TelegramClient: @@ -103,26 +103,6 @@ class TelegramClient: res = self._call("deleteMessage", params) return bool(res) - def send_message_chunked( - self, - chat_id: int, - text: str, - reply_to_message_id: Optional[int] = None, - disable_notification: bool = False, - chunk_len: int = DEFAULT_CHUNK_LEN, - ) -> List[Dict[str, Any]]: - sent: List[Dict[str, Any]] = [] - chunks = chunk_text(text, limit=chunk_len) - for i, c in enumerate(chunks): - msg = self.send_message( - chat_id=chat_id, - text=c, - reply_to_message_id=(reply_to_message_id if i == 0 else None), - disable_notification=disable_notification, - ) - sent.append(msg) - return sent - def send_message_markdown_chunked( self, chat_id: int,