Parent: #398
Depends on: Context Builder core selection and assembly model.
Goal
Show approximate token cost for selected context before launch, with per-file and total estimates plus clear over-budget warnings.
Implementation Notes
Add a model-agnostic estimator first; exact provider tokenizers are not required for this issue.
Suggested behavior:
- estimate tokens as roughly UTF-8 bytes / 4 with a small safety multiplier
- label all values as approximate
- calculate per-file and total selected context tokens
- keep token work off the main actor and cached by path/content fingerprint where practical
- warn when a selection exceeds a configured/default model window
- do not silently drop selected files
Wire estimates into the Context Builder UI. Smart-mode plan row estimates can be a follow-up unless this issue already has the necessary context payload in place.
Acceptance Criteria
- Selecting/deselecting files updates approximate per-file and total token counts.
- Over-budget context shows a visible warning.
- The app never silently removes files to fit a budget.
- Empty context and missing model/window information degrade gracefully.
Tests
Add pure tests for token estimation and truncation/warning thresholds if implemented. Add view-model tests for total-token updates.
Parent: #398
Depends on: Context Builder core selection and assembly model.
Goal
Show approximate token cost for selected context before launch, with per-file and total estimates plus clear over-budget warnings.
Implementation Notes
Add a model-agnostic estimator first; exact provider tokenizers are not required for this issue.
Suggested behavior:
Wire estimates into the Context Builder UI. Smart-mode plan row estimates can be a follow-up unless this issue already has the necessary context payload in place.
Acceptance Criteria
Tests
Add pure tests for token estimation and truncation/warning thresholds if implemented. Add view-model tests for total-token updates.