Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/coding_agent_telegram/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def _parse_allowed_chat_ids() -> set[int]:

out: set[int] = set()
for item in values:
out.add(int(item))
try:
out.add(int(item))
except ValueError:
raise ValueError(f"Invalid chat ID in ALLOWED_CHAT_IDS: {item!r}") from None
return out


Expand Down
41 changes: 0 additions & 41 deletions src/coding_agent_telegram/router/session_branch_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,6 @@ def _branch_discrepancy_keyboard(self, update: Update, stored_branch: str, curre
]
)

def _multi_branch_source_keyboard(
self,
*,
new_branch: str,
source_branches: list[str],
project_path,
) -> InlineKeyboardMarkup | None:
rows: list[list[InlineKeyboardButton]] = []
seen: set[tuple[str, str]] = set()
for source_branch in source_branches:
if not source_branch:
continue
row: list[InlineKeyboardButton] = []
if self.git.local_branch_exists(project_path, source_branch):
key = ("local", source_branch)
if key not in seen:
token = self._register_branch_source_token("local", source_branch, new_branch)
row.append(
InlineKeyboardButton(
f"local/{source_branch}",
callback_data=f"branchsource:{token}",
)
)
seen.add(key)
if self.git.remote_branch_exists(project_path, source_branch):
key = ("origin", source_branch)
if key not in seen:
token = self._register_branch_source_token("origin", source_branch, new_branch)
row.append(
InlineKeyboardButton(
f"origin/{source_branch}",
callback_data=f"branchsource:{token}",
)
)
seen.add(key)
if row:
rows.append(row)
if not rows:
return None
return InlineKeyboardMarkup(rows)

async def _offer_branch_source_fallback(
self,
query,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ async def _create_session_for_context(
stall_message=self._t(update, "runtime.replacement_session_stall"),
)

if result is None:
return False

if not result.success or not result.session_id:
await send_text(update, context, result.error_message or self._t(update, "lifecycle.failed_create_session"))
return False
Expand Down
6 changes: 3 additions & 3 deletions src/coding_agent_telegram/session_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from coding_agent_telegram.filters import is_sensitive_path, resolve_project_path
from coding_agent_telegram.git_utils import GitWorkspaceManager
from coding_agent_telegram.i18n import translate
from coding_agent_telegram.i18n import locale_from_update, translate
from coding_agent_telegram.session_store import SessionStore
from coding_agent_telegram.telegram_sender import (
markdownish_to_html,
Expand Down Expand Up @@ -129,12 +129,12 @@ async def store_photo(self, update: Update, project_folder: str) -> Path:
telegram_photo = update.message.photo[-1]
declared_size = getattr(telegram_photo, "file_size", None)
if isinstance(declared_size, int) and declared_size > self.MAX_PHOTO_BYTES:
raise PhotoAttachmentError("photo_too_large", translate("en", "runtime.photo_too_large"))
raise PhotoAttachmentError("photo_too_large", translate(locale_from_update(update), "runtime.photo_too_large"))

telegram_file = await telegram_photo.get_file()
content = bytes(await telegram_file.download_as_bytearray())
if len(content) > self.MAX_PHOTO_BYTES:
raise PhotoAttachmentError("photo_too_large", translate("en", "runtime.photo_too_large"))
raise PhotoAttachmentError("photo_too_large", translate(locale_from_update(update), "runtime.photo_too_large"))
suffix = Path(telegram_file.file_path or "image.jpg").suffix.lower() or ".jpg"
if suffix not in {".jpg", ".jpeg", ".png", ".webp", ".gif"}:
suffix = ".jpg"
Expand Down
Loading
Loading