-
Notifications
You must be signed in to change notification settings - Fork 32
🤖 feat: add auto-compaction with progressive warnings #683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+744
−131
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2029900
feat: add auto-compaction with progressive warnings
ethanndickson 3a272c7
fix merge conflict
ethanndickson 7e67829
use model options for 1m context
ethanndickson 683d9df
pass model and images when resuming
ethanndickson 686e439
fix usage calc
ethanndickson 8b68d16
fix usage calc
ethanndickson 444c3ba
🤖 refactor: make countdown warning smaller and less intrusive
ethanndickson 2f2d3eb
🤖 fix: prevent double-compaction when sending during active compaction
ethanndickson b184dcf
🤖 test: add comprehensive unit tests for shouldAutoCompact
ethanndickson 2c6f833
Merge remote-tracking branch 'origin/main' into frontend-auto-compact…
ethanndickson e41a38b
refactor merge commit changes
ethanndickson 1726268
fixup
ethanndickson b81219a
use pending model for auto compact check
ethanndickson 9ac0931
fixup
ethanndickson da1e3ae
fix mobile
ethanndickson 2456a85
call onMessageSent
ethanndickson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "lockfileVersion": 1, | ||
| "configVersion": 0, | ||
| "workspaces": { | ||
| "": { | ||
| "name": "@coder/cmux", | ||
|
|
||
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React from "react"; | ||
|
|
||
| /** | ||
| * Warning banner shown when context usage is approaching the compaction threshold. | ||
| * | ||
| * Displays progressive warnings: | ||
| * - Below threshold: "Context left until Auto-Compact: X% remaining" (where X = threshold - current) | ||
| * - At/above threshold: "Approaching context limit. Next message will trigger auto-compaction." | ||
| * | ||
| * Displayed above ChatInput when: | ||
| * - Token usage >= (threshold - 10%) of model's context window | ||
| * - Not currently compacting (user can still send messages) | ||
| * | ||
| * @param usagePercentage - Current token usage as percentage (0-100) | ||
| * @param thresholdPercentage - Auto-compaction trigger threshold (0-100, default 70) | ||
| */ | ||
| export const CompactionWarning: React.FC<{ | ||
| usagePercentage: number; | ||
| thresholdPercentage: number; | ||
| }> = (props) => { | ||
| // At threshold or above, next message will trigger compaction | ||
| const willCompactNext = props.usagePercentage >= props.thresholdPercentage; | ||
|
|
||
| // Urgent warning at/above threshold - prominent blue box | ||
| if (willCompactNext) { | ||
| return ( | ||
| <div className="text-plan-mode bg-plan-mode/10 mx-4 my-4 rounded-sm px-4 py-3 text-center text-xs font-medium"> | ||
| ⚠️ Context limit reached. Next message will trigger Auto-Compaction. | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| // Countdown warning below threshold - subtle grey text, right-aligned | ||
| const remaining = props.thresholdPercentage - props.usagePercentage; | ||
| return ( | ||
| <div className="text-muted mx-4 mt-2 mb-1 text-right text-[10px]"> | ||
| Context left until Auto-Compact: {Math.round(remaining)}% | ||
| </div> | ||
| ); | ||
| }; |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.