Skip to content

fix: /new command now cancels running processes (#222)#223

Merged
Nathan Schram (nathanschram) merged 2 commits intodevfrom
fix/new-cancel-running
Mar 23, 2026
Merged

fix: /new command now cancels running processes (#222)#223
Nathan Schram (nathanschram) merged 2 commits intodevfrom
fix/new-cancel-running

Conversation

@nathanschram
Copy link
Member

Summary

  • /new now cancels all running tasks for the chat before clearing sessions
  • Previously only cleared resume tokens, leaving old processes running (~400 MB each)
  • This leaked processes and worsened memory pressure, contributing to earlyoom kills (rc=143)
  • Reply message shows "cancelled run and cleared" when a process was killed

Closes #222

Changes

  • src/untether/telegram/commands/topics.py_cancel_chat_tasks() helper; updated both /new handlers
  • src/untether/telegram/loop.pyrunning_tasks in TelegramCommandContext; passed through all call sites
  • tests/test_telegram_topics_command.py — 10 new tests
  • 7 docs updated to reflect new /new behaviour
  • Bumped to 0.35.0rc12

Test plan

  • Unit tests: 1803 passed, 81.37% coverage
  • Integration tested via @untether_dev_bot:
    • Claude: /new while running → cancelled + cleared
    • Codex: /new while running → cancelled + cleared
    • OpenCode: /new while running → cancelled + cleared
    • No running task: shows "cleared stored sessions"
  • Logs show new.cancelled_running event with chat_id and count
  • No errors or warnings in dev bot logs

🤖 Generated with Claude Code

…ons (#222)

Previously /new only cleared stored resume tokens, leaving old Claude/Codex/OpenCode
processes running (~400 MB each). This leaked processes and worsened memory pressure,
contributing to earlyoom kills (rc=143).

Now /new cancels all running tasks for the chat before clearing sessions. Reply
message shows "cancelled run and cleared" when a process was killed.

- Add _cancel_chat_tasks() helper to topics.py
- Add running_tasks param to both /new handlers
- Pass running_tasks through all 3 call sites in loop.py
- Add running_tasks field to TelegramCommandContext
- 10 new tests covering cancellation behaviour
- Update 7 docs to reflect new /new behaviour
- Bump version to 0.35.0rc12

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f8a2ff4-3a26-4b6a-8fb1-09b0e702a808

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/new-cancel-running

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nathanschram Nathan Schram (nathanschram) merged commit 98912b4 into dev Mar 23, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant