mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 08:59:40 +02:00
feat(tiles): each tile header names its harness and model
The tile header is now `● [logo] name · model ..... ⋯ ⤢ ×` (owner request): - The logo is PR #532's `run-mode-dot <cliId>` slot, so the logos, the skins and the plain dot of an id without a logo stay single-sourced in styles.css. The id is data (a class and a catalog lookup), never a branch; the frontend id-branching guard now also scans constants.js, terminal-split.js and tile-grid.js (the one existing shell branch in tile-grid.js, the attach route, is allowlisted with its reason). - The model is the session's displayModel, as text in a data-i18n-skip span inside a box whose tooltip may translate. Unknown means the logo alone. - The logo's tooltip and accessible name say "<harness> · <model>", plus where a model the CLI did not report came from ("set at launch", "custom endpoint"; zh-CN patterns for both, the names pass through). The model's box is aria-hidden so a screen reader hears the model once. - One painter, _paintSessionHarness (terminal-split.js, shared with the split panes next), diffs against what it last wrote, never the DOM: an unchanged session writes nothing on a tab render. - On a narrow header the model gives way first, then the name: the name does not shrink at all and is capped at its box, since any shrink factor takes a subpixel from a name that fits and ellipsizes it. The chrome and zoom tests found header parts by child position; they now look them up by class, with every assertion kept (the rename tests had been passing against the new logo node by position). The i18n harvester files the logo's labels as harness and model names that must stay as they are. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2134,7 +2134,56 @@ function sessionIdFromFragment(hash) {
|
||||
return id && id.trim() ? id.trim() : null;
|
||||
}
|
||||
|
||||
/** Longest model name a session header shows (the server caps it as well). */
|
||||
const SESSION_MODEL_MAX_CHARS = 64;
|
||||
/** A CLI registry id (src/config/cli-registry/schema.ts); anything else is not a class name. */
|
||||
const CLI_ID_PATTERN = /^[a-z][a-z0-9-]{0,23}$/;
|
||||
|
||||
/**
|
||||
* What a session's header says about its harness: the CLI id (the
|
||||
* `run-mode-dot <id>` logo class), the registry's label for it, the model the
|
||||
* session runs when the server knows it (`SessionState.displayModel`), and the
|
||||
* tooltip naming both.
|
||||
*
|
||||
* The id is data: the label comes from the injected CLI catalog and falls back
|
||||
* to the id, so a CLI added through clis.json still gets a name. The model is
|
||||
* untrusted text (read off a pane, or a CLI's own report): control characters
|
||||
* are dropped and the length capped here too, and callers render it with
|
||||
* textContent. The tooltip says where a model that is not the CLI's own report
|
||||
* came from, so it never claims more than the server knows: one the session
|
||||
* was launched with may have been switched since, and a custom endpoint's
|
||||
* model is the endpoint's, whatever the CLI calls it.
|
||||
*
|
||||
* @param {object} session - a session from app.sessions
|
||||
* @param {Array<{id: string, label?: string}>} [catalog] - window.__codemanCliCatalog
|
||||
* @returns {{id: string, label: string, model: string, title: string}}
|
||||
*/
|
||||
function describeSessionHarness(session, catalog) {
|
||||
const id = typeof session?.mode === 'string' && CLI_ID_PATTERN.test(session.mode) ? session.mode : '';
|
||||
const entry = id && Array.isArray(catalog) ? catalog.find((cli) => cli?.id === id) : null;
|
||||
const label = (typeof entry?.label === 'string' && entry.label.trim()) || id;
|
||||
const raw = session?.displayModel?.model;
|
||||
const model =
|
||||
typeof raw === 'string'
|
||||
? raw
|
||||
.replace(/[\u0000-\u001f\u007f-\u009f]/g, '')
|
||||
.trim()
|
||||
.slice(0, SESSION_MODEL_MAX_CHARS)
|
||||
: '';
|
||||
const source = session?.displayModel?.source;
|
||||
const qualifier = !model
|
||||
? ''
|
||||
: source === 'launch'
|
||||
? ' (set at launch)'
|
||||
: source === 'custom-endpoint'
|
||||
? ' (custom endpoint)'
|
||||
: '';
|
||||
const title = [label, model].filter(Boolean).join(' \u00B7 ') + qualifier;
|
||||
return { id, label, model, title };
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.CodemanSessionHarness = { describeSessionHarness, SESSION_MODEL_MAX_CHARS };
|
||||
window.CodemanHistoryFormat = { formatHistoryBytes, computeHistoryTruncationNotice, computeRewriteScrollLine };
|
||||
window.CodemanFilePaths = { absoluteFilePathPattern, previewsInFileViewer, FILE_PREVIEW_EXTENSIONS };
|
||||
window.CodemanTerminalLines = { terminalLogicalLine };
|
||||
|
||||
Reference in New Issue
Block a user