Commit Graph

8 Commits

Author SHA1 Message Date
Alishahryar1 64e5b10612 Refactor done by z-ai/glm5 2026-02-14 18:47:26 -08:00
Cursor Agent 1cface7f8c Fix all ty check errors without using type: ignore
- messaging/telegram.py: Remove unused type: ignore, fix retry_after typing
  with isinstance(timedelta), use local app variable for None narrowing
- messaging/tree_data.py: Replace _queue._queue access with drain-and-restore
  approach for get_queue_snapshot (avoids private API)
- tests/test_api.py: Use APIError instead of RuntimeError for status_code test
- tests/test_config.py: Use cast(Any, ...) for invalid validation tests
- tests/test_dependencies.py: Add isinstance check for NvidiaNimProvider
- tests/test_handler_markdown_and_status_edges.py: Use patch.object for
  tree_queue method mocks
- tests/test_response_models.py: Add isinstance narrowing for content blocks,
  use Literal list for stop_reason parametrization
- tests/test_restart_reply_restore.py: Use patch.object for enqueue mock
- tests/test_server_module.py: Use patch.object for uvicorn.run and
  get_settings
- tests/test_telegram_edge_cases.py: Use patch.object for method mocks
- tests/test_tree_concurrency.py: Add None assertions for get_node/get_tree

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 02:28:33 +00:00
Cursor Agent 959d1bdf5b Phase 5: Encapsulation - Repository and MessageTree API
TreeRepository:
- Add has_node(node_id) -> bool
- Add tree_count() -> int

MessageTree:
- Add cancel_current_task() -> bool
- Add drain_queue_and_mark_cancelled() -> List[MessageNode]
- Add reset_processing_state()
- Add current_node_id property

TreeQueueManager:
- Remove _trees and _node_to_tree properties
- add_to_tree: use has_node() and get_tree_for_node()
- get_tree_count: use repository.tree_count()
- cancel_tree: use tree.cancel_current_task(), drain_queue_and_mark_cancelled(), reset_processing_state()

TreeQueueProcessor:
- cancel_current: delegate to tree.cancel_current_task()

Tests: update to use get_tree_count(), has_node(), get_tree_for_node()

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 01:38:35 +00:00
Cursor Agent 952e40dae7 Phase 4: O(1) find_node_by_status_message via reverse index
- Add _status_to_node: Dict[str, str] (status_msg_id -> node_id)
- Populate in __init__ (root), add_node, and from_dict
- find_node_by_status_message: O(n) -> O(1) lookup

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 01:37:00 +00:00
Cursor Agent c4b52cb4ce Remove dead code: MessageTree.get_queue_position
Method always returned 0 and was never called. Queue positions
are computed on-the-fly in _update_queue_positions via get_queue_snapshot.

Co-authored-by: Ali Khokhar <alishahryar2@gmail.com>
2026-02-15 01:31:26 +00:00
Alishahryar1 6d8f13d84e Added feature to update queue positions on telegram when messages are dequeued and added new tests 2026-02-08 04:00:58 -08:00
Alishahryar1 8ce86f4267 fixed type errors 2026-01-31 14:13:09 -08:00
Alishahryar1 3b037932d7 refactor to reduce coupling 2026-01-30 13:39:40 -08:00