Repository navigation
fix(tui): status do modelo fixo à direita no seletor, com reticências em nomes longos - #881
Conversation
Pinned rows rendered the status inside titleView, which bypasses the option's Locale.truncate, so long model names clipped mid-word and the last-check age held the right cell. Give the status its own right-aligned footer cell, restore native ellipsis truncation with a width budget from the terminal dimensions, and drop the age (staleness already degrades to unknown). Add a regression test that mounts the real DialogModel at 56 and 100 columns.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
…e names Extend the model-picker regression test: mock /provider/probe to render working, degraded and failing rows and assert the status cells share one right edge even though degraded is a column wider; pin a long favorite as the current selection to prove the marker column is accounted for; and probe a CJK-heavy name that overflows the character-counted truncation budget to prove the status cell survives wide titles.
Scope the probe interval down to 25ms for the health-state test instead of waiting out three real 15s ticks: the full probe pipeline (mocked /provider/probe, outcome mapping, store, re-sort) still runs end to end, but the test settles in ~150ms, keeps the default failure mode of waitFor (OutputBusy-only retry, frame dump on exhaustion) and restores setInterval before dispose.
| : model.cost?.input === 0 && provider.id === "opencode" | ||
| ? "Free" | ||
| : undefined, | ||
| titleWidth: |
There was a problem hiding this comment.
SUGGESTION: titleWidth can become negative on narrow terminals
titleWidth = rowBudget() - descriptionLength - 1 - statusLength - 1. With rowBudget floored at 24 and long provider names, this subtraction can yield a negative or zero width, which may cause the Option component to render incorrectly. Consider clamping with Math.max(0, ...) or a minimum usable width.
| value: { providerID: provider.id, modelID: model }, | ||
| title: info.name ?? model, | ||
| releaseDate: info.release_date, | ||
| description, |
There was a problem hiding this comment.
SUGGESTION: titleWidth can become negative on narrow terminals
Same pattern as the Pinned/Recent path: titleWidth = rowBudget() - descriptionLength - 1 - freeLength - 1. On narrow terminals with long provider names, this can produce negative values. Consider clamping to a minimum width.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Previous Review Summary (commit 9c2790e)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 9c2790e)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Reviewed by free · Input: 144.3K · Output: 2.3K · Cached: 72.2K |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
A provider description longer than the row budget drove titleWidth negative, and Locale.truncate's slice(0, len - 1) then counts from the end of the string, producing a title longer than the budget and reintroducing overflow. Clamp at a minimum width and cover it with a regression test using a 46-column provider name.
…d row Replace the frame-length containment claim (a char frame cannot show overflow past a clipping box, so it proved nothing) with assertions the frame does support: the clamped title is exactly ellipsized, and the clipped provider description remains a clean prefix of its source.
Issue for this PR
Closes #883
Type of change
What does this PR do?
No seletor de modelos (
/models), as linhas Pinned renderizavam nome + status viatitleView, que contorna oLocale.truncatedoOption— nomes longos cortavam no meio da palavra, e a célula da direita mostrava a idade do último check em vez do status.A mudança (confinada a
packages/tui/src/component/dialog-model.tsx):titleViewremovido das linhas Pinned: o título volta ao truncate nativo com…, comtitleWidthcalculado do terminal (max(24, min(60, dims-2) - 10)menos o comprimento real de status/descrição/Free), aplicado em Pinned, Recent e All models;● working/degraded/failing/unknown, colorido) passa aofooterda linha, que oOptionancora à direita;unknown).O mecanismo de sonda de saúde não muda; nada fora do seletor.
How did you verify your code works?
Novo teste de regressão
packages/tui/test/cli/tui/model-picker-status.test.tsxmonta oDialogModelreal (fixture de providers + favoritos semeados, probe de/provider/probemockado) e verifica: status ancorado à direita em todas as linhas Pinned a 56 colunas (incluindo com o favorito longo como seleção atual e comdegraded, 1 coluna mais largo),…em nomes longos a 56, nome completo a 100, sem idade do check. Os quatro estados de saúde passam pelo pipeline real de sonda com o intervalo de 15s reduzido a 25ms com escopo de teste. 5/5 verdes localmente (~3s),pollinations-model-listverde, prettier limpo.Screenshots / recordings
Capturas do
DialogModelreal desta branch a 56 e 100 colunas (incluindo os três estados coloridos) foram compartilhadas no review.Checklist