Skip to content

Conversation

@taetaetae
Copy link

@taetaetae taetaetae commented Jan 31, 2026

Summary

Add stepped context window warnings instead of a single 70% threshold notification.

Changes

  • Replace single 70% threshold with progressive warnings at 50%, 60%, 70%, 80%
  • Add ANSI color coding for visual urgency differentiation:
    • 📊 50% (INFO) - Blue
    • 📈 60% (NOTICE) - Yellow
    • ⚠️ 70% (WARNING) - Orange
    • 🚨 80% (CRITICAL) - Red
  • Track notified thresholds per session to avoid duplicate alerts at the same level
  • Each threshold triggers once with appropriate urgency messaging

Motivation

Previously, users only received a single notification at 70% context usage. By the time they noticed, it was often too late to wrap up work before hitting the 80%+ limit where sessions can become unresponsive.

With progressive warnings, users get early awareness (50%, 60%) and can plan accordingly, with increasingly urgent notifications as context fills up.

Testing

  • bun run typecheck passes
  • bun run build succeeds
  • Tested locally with OpenCode

Screenshots

N/A (terminal color output)


Summary by cubic

Replace the single 70% context alert with progressive warnings at 50%, 60%, 70%, and 80% to give earlier, clearer signals. Adds color-coded urgency and triggers each level only once per session.

  • New Features
    • Stepped thresholds: 50% INFO (blue), 60% NOTICE (yellow), 70% WARNING (orange), 80% CRITICAL (red).
    • Higher-level triggers mark lower levels to prevent out-of-order alerts; cleanup on session deletion.
    • Colored status line shows used/remaining tokens; guarded for Anthropic and degrades gracefully on errors.

Written for commit a0ded61. Summary will update on new commits.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Confidence score: 4/5

  • This PR looks safe to merge with low risk; the single issue is moderate severity (4/10) and mainly affects warning ordering rather than core functionality.
  • In src/hooks/context-window-monitor.ts, skipped thresholds can lead to lower-urgency warnings firing after a critical warning, which may confuse users monitoring usage levels.
  • Pay close attention to src/hooks/context-window-monitor.ts - threshold notification order and backfilled warnings.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/hooks/context-window-monitor.ts">

<violation number="1" location="src/hooks/context-window-monitor.ts:122">
P2: Only the highest threshold is marked as notified, so if usage skips thresholds (e.g., 40% → 80%), subsequent runs will emit lower-urgency warnings after the critical warning. This creates out-of-order backfilling of alerts and likely defeats the intended progressive warning behavior.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@taetaetae taetaetae force-pushed the feat/progressive-context-warnings branch from da08a63 to 0706e36 Compare January 31, 2026 17:48
github-actions bot added a commit that referenced this pull request Jan 31, 2026
@taetaetae taetaetae force-pushed the feat/progressive-context-warnings branch from d52d829 to 1584137 Compare January 31, 2026 17:51
@taetaetae
Copy link
Author

Thanks @cubic-dev-ai for catching this issue!

Fixed in the latest commit - now when a threshold is triggered, all lower thresholds are also marked as notified. This prevents out-of-order warnings when usage jumps (e.g., 40% → 80%).

…0%, 80%

- Replace single 70% threshold with progressive warnings
- Add ANSI color coding for visual urgency (blue → yellow → orange → red)
- Track notified thresholds per session to avoid duplicate alerts
- Mark all lower thresholds as notified to prevent out-of-order warnings
- Each threshold triggers once with appropriate urgency level:
  - 50% INFO: checkpoint notification
  - 60% NOTICE: awareness notification
  - 70% WARNING: caution notification
  - 80% CRITICAL: urgent action needed
@taetaetae taetaetae force-pushed the feat/progressive-context-warnings branch from 1584137 to a0ded61 Compare January 31, 2026 17:52
0WD0 pushed a commit to 0WD0/oh-my-opencode that referenced this pull request Feb 1, 2026
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