Repository navigation
fix(context): run the manual compaction in the background - #305
Merged
Merged
Conversation
The Compact confirmation awaited session.summarize inside the callback handler, so the sequential update loop was blocked for the whole compaction (minutes on a large context): commands, /detach included, waited behind it and were then dropped as stale. Start the compaction in the background and report its result through the progress message.
atn18
force-pushed
the
fix/compact-background
branch
from
November 20, 2026 17:42
9f8eccf to
9384940
Compare
atn18
marked this pull request as ready for review
November 20, 2026 19:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
opencodeClient.session.summarize(...)inside the grammY callback handler. grammY processes updates sequentially, so the whole update loop stayed blocked while the compaction ran (minutes on a large context): every command,/detachincluded, waited behind it, and queued messages older than 60 seconds were then dropped as stale with the "Telegram was unreachable" notice.safeBackgroundTask, like the start-only prompt path), and the progress message is updated from its hooks:context.successwhen it completes,context.errorwhen it returns an error or throws. The handler answers the callback, cleans up the menu, sends the progress message and returns immediately, so commands keep working while the compaction runs.Closes issue (optional)
How it was tested
npm run lint,npm run build,npm run typecheck,npm test- all green (3557 passed, 7 skipped).context.successafter it resolves; a second confirmation while a compaction is in flight is rejected with the existing "compacting" toast and starts no second summarize; a failed compaction (error object and thrown rejection) reports throughcontext.errorwithout failing the handler and releases the guard. The existing success case now waits for the asynchronous edit.Checklist
<type>(<scope>)?: <description>mainnpm run lint,npm run build, andnpm test