feat: add context-window meter and in-conversation search to TUI
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #1363 di @avoidwork — integrata
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- cli
Direzione di ricerca
Start with the context-window meter in src/tui/statusBar.js, where contextSize is currently rendered via formatSize in the showContext block, and reuse getContextUtilizationColor for the ratio. Search (Ctrl+F) spans src/tui/app.js, messageList.js and scrollView.js, and the issue itself recommends splitting it out, so confirm scope with the maintainer first. Done means the meter renders at 0%, 50%, 100% and falls back when contextWindow is unset, with tests passing via npm run test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Add a context-window meter to the TUI status bar (replacing the bare contextSize number with a visual bar) and add in-conversation search (Ctrl+F) with match highlighting and jump-to-next.
Motivation
The status bar currently shows a bare contextSize number, which is not intuitive — users cannot tell at a glance how much of the context window is consumed. Long conversations are also hard to navigate; in-conversation search lets users filter and jump to specific messages without scrolling through the whole transcript.
Proposed Solution
- Context-window meter — Replace the bare
contextSizenumber insrc/tui/statusBar.jswith a visual bar, e.g.[▮▮▮▯▯▯] 62%, showing the proportion of the context window used. - In-conversation search — Bind Ctrl+F to filter/search messages, with match highlighting and jump-to-next. Builds on the virtualized
src/tui/scrollView.jsandsrc/tui/messageList.js.
Dependencies
- No new runtime dependencies expected — this builds on the existing TUI rendering stack. If a search/filter helper is required, prefer a lightweight in-house implementation over adding a dependency. Confirm exact packages during implementation.
Testing Strategy
- Unit tests: Verify the meter renders correctly at 0%, 50%, and 100% context usage; verify search/filter logic matches expected messages and highlights matches.
- Integration test: Simulate Ctrl+F in the TUI, type a query, and verify matches are highlighted and jump-to-next advances through results.
- Edge cases: Empty conversation, no matches found, very long messages, context at 0% and 100%, search query with special characters.
Security Considerations
- Credential storage: Not applicable — no credentials involved.
- Input validation: Validate and sanitize the search query before filtering; guard against regex injection if the query is used in a regex.
- OWASP: No new attack surface beyond normal TUI input handling.
Alternatives Considered
- Meter: Keep the bare number, or show only a percentage. A visual bar was chosen for at-a-glance readability.
- Search: A separate search panel vs. inline filter. Inline filter with jump-to-next was chosen for minimal disruption to the existing scroll view.
Split Recommendation
This issue bundles multiple distinct capabilities. Consider splitting into separate issues:
- Context-window meter — small, self-contained change to
src/tui/statusBar.js. - In-conversation search — larger, touches
src/tui/scrollView.jsandsrc/tui/messageList.js, and requires keyboard handling.
MVP recommendation: Start with the context-window meter as it has the least dependencies and highest immediate value.
OpenSpec Note
This project uses OpenSpec for feature development. If this request is approved, I will:
- Run
/opsx:proposeto generate a full proposal with specs and tasks - Iterate on the design before any code is written
- Follow the task-driven implementation workflow
Additional Context
Split out from issue 1339.
Audit Findings (for Issue #1357)
src/tui/statusBar.js— ThecontextSizevalue is rendered viaformatSize(contextSize)in theshowContextblock (around line 117). ThecontextWindowprop is already available, andgetContextUtilizationColor(contextSize, contextWindow)already computes the utilization percentage. The meter can reuse this: computecontextSize / contextWindowand render a bar like[▮▮▮▯▯▯] 62%. Handle thecontextWindow <= 0(unset) case — currentlygetContextUtilizationColorfalls back to cyan; the meter should fall back to the bare number or a neutral display.src/tui/scrollView.js—VirtualScrollViewexposes an imperative API via ref:scrollTo,scrollBy,scrollToTop,scrollToBottom,getScrollOffset,getContentHeight,getViewportHeight,getBottomOffset,remeasure,remeasureItem. It renders only the visible window viacomputeVisibleRange(heights, viewportHeight, scrollOffset, overscan). For jump-to-next, compute the matched message's cumulative offset from theoffsetsarray and callscrollTo(offset).src/tui/messageList.js—MessageListbuildsrenderData(filtered byshouldRenderBubble) andtextOffsetsfor selection mapping. It exposesgetMessages()returning{text, top}per message — search can reuse this to locate matches and compute the scroll target. TherenderItemalready accepts aselectionprop (global char range mapped to a local bubble range) and passes it toMessageBubble— search match highlighting can reuse this selection mechanism.src/tui/app.js— The globaluseInputhandler (line 367) routes keys in conversation view. Ctrl+F is not currently handled; add akey.ctrl && input === "f"branch to toggle search mode. Note the existing focus-aware routing (tab togglesinputFocused), so search mode must coordinate with input focus.src/tui/inputArea.js— PassescontextSizeandcontextWindowtoStatusBar(lines 191-195). No change needed here for the meter; the data source already exists.
Fix Steps
- Add the context-window meter — In
src/tui/statusBar.js, replace theformatSize(contextSize)render in theshowContextblock with a visual bar. Computeutilization = contextWindow > 0 ? contextSize / contextWindow : 0, render[▮▮▮▯▯▯] 62%using block characters, and color it via the existinggetContextUtilizationColor. Fall back to the bare number whencontextWindow <= 0. - Add a search state to MessageList — In
src/tui/messageList.js, add asearchQuerystate and asearchIndex(current match). Add asetSearchQuery/clearSearchimperative API. ReusegetMessages()to find matches and compute the scroll target offset. - Highlight matches — In
src/tui/messageList.jsrenderItem, when a search query is active, compute the local match ranges within each bubble's text and pass them toMessageBubble(reuse the existingselectionprop mechanism or add ahighlightsprop). - Wire Ctrl+F — In
src/tui/app.js, add akey.ctrl && input === "f"branch in the globaluseInputhandler to toggle search mode and focus the search input. Coordinate with the existinginputFocusedrouting so search mode takes precedence. - Add jump-to-next — In
src/tui/messageList.js, add asearchNext/searchPrevimperative method that advancessearchIndexand callsscrollRef.current.scrollTo(offset)using the matched message's cumulative offset. - Write tests — Add unit tests for the meter (0%, 50%, 100%, and unset contextWindow) and for search matching/highlighting/jump-to-next. Add an integration test simulating Ctrl+F. Run
npm run test,npm run lint, andnpm run coverage.
- Lingua principale
- JavaScript
- Stelle
- 2
- Fork
- 0
- Merge medio
- 1h 34m
- PR unite (30g)
- 231
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di avoidwork/madz
-
fix: show file picker empty message below the input lineForse già presa @avoidwork l’ha presa oggi. Apertaapproved bug in progress
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
avoidwork/madz#1412 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di avoidwork/madz
Issue simili
-
Four problem loader browser tests fail on WindowsForse già presa @Patriciaath999 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
juice-shop/juice-shop#3686 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ScottKirvan/GOMAC#56 ·
-
area:install bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
yetone/magpie#2406 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno