routing: a session named by a prompt of many lines is one line in its block, with its bar shown (tz_188 on Discord)
tz_188's ZCode card on Routing had a session whose title was a long
Chinese prompt, and its text ran over the rest of the block. A session's
name comes from its first prompt as written, line breaks included; the
name's box is one line tall with an ellipsis, but a break (U+2028 in
WebKit, a newline elsewhere) still wrapped it, so the second line drew
over the context bar beneath. titleOf and sessionName now fold every run
of white space (U+0085 too) to one space, so the name is one line and
ends in its ellipsis. The bar under it (.rt-ctx-s .ctx-stack) had
flex: 1 in a column box and could be squeezed to 0px by a long name; it
is now flex: none, full width, 4px.
Run (mote, via mote-run, Playwright chromium + webkit):
- routing-ctx-sessions.test.cjs, with a new case of a long CJK prompt of
several lines (\n and U+2028): en, zh, zh-TW, ja, de at 1100, 700 and
390px: 56/56 pass.
- the whole routing-* GUI set at this commit: 2870 of 2910 pass. The 40
reds are in i18n-keys (#5332, #5426), routing-intent-entry (#5392),
many-keys, order-unknown, row-swap, rule-drag, rule-remove, steady,
steps-cap and story-shrinks. Those nine files run again alone, here and
at origin/main cff530079: 39 red here, 34 at main, the same files
(filed: #5088, #4628, #4627, #4629, #3799, #3789, #3096, #1804); the
count moves with mote's load (another session's full GUI run).
Broken by hand: titleOf/sessionName without the fold, webkit 15/15 red
("name drawn on one line: 33.59px vs 15.39px"); the CSS put back, 32 red
("bar keeps its 4px: 0").
Not tried: the reporter's own title bytes (only the screenshot; the
overlap was reproduced with a break in the name, not with their text),
the real app's WKWebView, Windows and Linux.
Reported-by: tz_188
This commit is contained in:
@@ -1548,11 +1548,16 @@ function routingPage(part) {
|
||||
// the title of the session a request is of, as its agent named it, or
|
||||
// nothing: never one matched to it by its prompt (parentMatched), which
|
||||
// the list's head says is a guess (connor_yang on Discord)
|
||||
const titleOf = (r) => !r || r.parentMatched ? "" : r.agent === "codex" ? codexNames.get(groupSession(r)) || "" : otherTitles.get(ownKey(r)) || "";
|
||||
const titleOf = (r) => oneLine(!r || r.parentMatched ? "" : r.agent === "codex" ? codexNames.get(groupSession(r)) || "" : otherTitles.get(ownKey(r)) || "");
|
||||
// sessionName is what a request's session is called where it has a
|
||||
// name: its agent's title for it (the trace's, or one read since), else
|
||||
// nothing
|
||||
const sessionName = (r) => r.sessionTitle || titleOf(r) || "";
|
||||
const sessionName = (r) => oneLine(r.sessionTitle) || titleOf(r);
|
||||
// oneLine is a title as one line. A title is often its session's first
|
||||
// prompt, and WebKit breaks a line at U+2028/U+2029 even under nowrap, so
|
||||
// a session's block meant for one line of it stacked every line of the
|
||||
// prompt (tz_188 on Discord)
|
||||
function oneLine(s) { return s ? String(s).replace(/[\s\u0085]+/g, " ").trim() : ""; }
|
||||
const subs = new Map(); // a group in the group's way down → its heading { li, wire, key, up }
|
||||
// A provider's keys serving one model, FOLD_AT or more of them side by
|
||||
// side, fold into one row that tells of them all (#1319: 53 keys for one
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
.rt-ctx-s[aria-pressed="true"] { background: var(--card-2); color: var(--fg); }
|
||||
.rt-ctx-s .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
|
||||
.rt-ctx-s .sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.rt-ctx-s .ctx-stack { display: flex; max-width: none; width: 100%; height: 4px; border-radius: 2px; }
|
||||
.rt-ctx-s .ctx-stack { flex: none; display: flex; max-width: none; width: 100%; height: 4px; border-radius: 2px; }
|
||||
.rt-log-head { display: flex; flex-wrap: wrap; align-items: center; row-gap: 2px; font-size: 12px; font-weight: 600; color: var(--fg); }
|
||||
.rt-log-head .grow { flex: 1; }
|
||||
/* a request's request and response, opened from the story's head */
|
||||
|
||||
@@ -173,4 +173,43 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual((await blocks(page)).map((b) => b.name), ["docs", SESS.a.title]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
// tz_188 on Discord: ZCode's sessions are named by their first prompt,
|
||||
// a long Chinese one of several lines. WebKit breaks a line at U+2028
|
||||
// and U+2029 even where a name is kept to one, so each block stacked
|
||||
// the prompt's lines. Its bar took context.css's flex: 1 1 0, so in a
|
||||
// block as tall as its lines it was 0px high, and in a shorter block
|
||||
// beside a taller one it stretched to fill it. Each name is one line in
|
||||
// every block, at every width, in every language, and every bar is 4px.
|
||||
test(`${engine}: a session named by a prompt of many lines is one line in its block`, async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
t.after(() => browser.close());
|
||||
const prompt = "你的唯一任务是采集并分析用户提供的所有网页内容,逐条提取关键信息。\u2028要求:\u2029一、严格按照格式输出;\r\n二、保留原文中的数字与链接;\u0085三、不要遗漏任何一条。\n\n";
|
||||
const titles = { a: SESS.a.title, b: SESS.b.title };
|
||||
t.after(() => { SESS.a.title = titles.a; SESS.b.title = titles.b; });
|
||||
SESS.a.title = prompt.repeat(40);
|
||||
SESS.b.title = prompt;
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
for (const width of [1100, 700, 390]) {
|
||||
await t.test(`${lang} ${width}px`, async () => {
|
||||
const { context, page, errors } = await open(browser, lang, width, [req(101, "a"), req(102, "b"), req(103, "a")]);
|
||||
t.after(() => context.close());
|
||||
await page.locator(".rt-ctx-sess:not([hidden]) .rt-ctx-s").nth(1).waitFor();
|
||||
const got = await page.$$eval(".rt-ctx-s", (bs) => bs.map((b) => {
|
||||
const h = (q) => b.querySelector(q).getBoundingClientRect().height;
|
||||
return { name: b.querySelector(".nm").textContent, nm: h(".nm"), sub: h(".sub"), bar: h(".ctx-stack") };
|
||||
}));
|
||||
assert.equal(got.length, 2);
|
||||
for (const g of got) {
|
||||
assert.ok(!/[\n\r\u2028\u2029\u0085]/.test(g.name), `the name is one line of text: ${JSON.stringify(g.name.slice(0, 80))}`);
|
||||
assert.ok(g.name.startsWith("你的唯一任务是采集并分析用户提供的所有网页内容,逐条提取关键信息。 要求: 一、"), g.name.slice(0, 80));
|
||||
assert.ok(g.nm < 2 * g.sub, `the name is drawn on one line: ${g.nm}px against the sub-line's ${g.sub}px`);
|
||||
assert.equal(Math.round(g.bar), 4, `the bar keeps its 4px: ${g.bar}`);
|
||||
}
|
||||
const crumbs = await page.locator(".rt-ctx .ctx-crumbs").textContent();
|
||||
assert.ok(!/[\n\r\u2028\u2029\u0085]/.test(crumbs), "the card's crumbs name it on one line too");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user