Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 14 additions & 29 deletions .artifacts/1843/state-coverage.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,29 @@
{
"task": "1843-tab-fixed-width-ellipsis",
"task": "1843-proportional-shrink",
"states": [
{
"state": "01-long-ellipsis",
"screenshot": ".artifacts/1843/01-long-ellipsis.png",
"state": "01-long-cap-ellipsis",
"screenshot": "01-title-ellipsis.png",
"assertion": "passed",
"width": 256,
"tabMax": 256,
"ellipsis": true
"detail": "长名省略号+上限钳制:长页签 256.0px ≈ tabMaxWidth 256px,短页签 118.4px"
},
{
"state": "02-short-actual",
"screenshot": ".artifacts/1843/02-short-actual.png",
"state": "04-narrow-proportional-shrink",
"screenshot": "03-narrow-proportional-shrink.png",
"assertion": "passed",
"shortWidths": [
130,
133
]
"detail": "窄视口同比例收缩:宽 [144,143,144,144,144,143,144,146] → 窄 [31,31,31,31,31,31,31,31],scrollWidth 538 ≤ clientWidth 538"
},
{
"state": "03-not-fill-tail",
"screenshot": ".artifacts/1843/03-not-fill-tail.png",
"state": "02-short-actual",
"screenshot": "06-single-short-tab.png",
"assertion": "passed",
"clientWidth": 1238,
"usedWidth": 519
"detail": "短名按实际宽度:页签 74.5px < tabMinWidth 96px(未被撑到保底)"
},
{
"state": "04-narrow-shrink",
"screenshot": ".artifacts/1843/04-narrow-shrink.png",
"state": "03-not-fill",
"screenshot": "07-short-vs-long.png",
"assertion": "passed",
"wide": [
256,
130,
133
],
"narrow": [
256,
106,
108
]
"detail": "不铺满/不伸展:短 74.2px < 长 256.0px ≈ 上限 256px"
}
]
}
}
1 change: 1 addition & 0 deletions docs/design/system/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ ledger: append-only
| 图标纪检高频 18px 裁决(批次) | 11 个高频 18px 图标逐个对照 spec §2.1(24 网格 / ≤6 笔画 / 尺寸档)、§2.2(`fill="currentColor"`,描边写 `fill="none"` + `stroke-width 1.7`,禁止内联一次性 SVG)、§2.4(可逆动作成对)后**全部维持现状**:无面/线混用、无第四档尺寸、无单向孤儿;明细见本行下方表 | ui-quality-primitives-v1 / 2.5 / #1711 | 2026-11-28 |
| 信息窗复制图标弱化档 | 新增 `--app-text-4`(spec §6 文本弱化档):信息窗复制路径 / 复制文件两图标默认色由 `--app-text-3` 降为该档,hover 提亮到 `--app-text`;该档仅用于低干扰辅助图标静息态,不用于任何文本;标题与路径保持左对齐 | editor-surface-batch24 / #1856 | 2026-11-30 |
| 画面按钮图标定案 | 取代台账「画面图标(#486):图片框构图(山与太阳)」行:控制条「画面」按钮改用「显示器 + 播放三角」(外框 + 底座 + 三角,单 `s` path,§2.1 安全区 / ≤6 笔画);新增 `visual` 概念键,与 `video` 文件类型图标(外框 + 三角)不同构图、不复用 path;两套图标源 + e2e mock 三处同步 | editor-surface-batch24 / #1857 | 2026-11-30 |
| 页签同比例收缩 | #1843 在固定上限模型上补「变窄时同比例收缩」:页签 `flex: 0 1 auto` + `min-width: 0` + `flex-shrink: 1`,移除 `calc-size(max-content, min(...))` 保底(WebKit 不支持),`--tab-min-width` 不再作收缩下限;短名按内容实际宽度、长名以 `--tab-max-width` 为上限并省略号收尾,全部页签在窗格变窄时按同一比例连续收缩 | #1843 | 2026-12-02 |

**图标纪检 18px 高频裁决明细(11 行,spec §2.1 / §2.2 / §2.4)**

Expand Down
8 changes: 4 additions & 4 deletions docs/design/system/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,17 @@ token 缺失时组件按 `var(--sf-ctrl-height, 27px)` 回落,不静默失效

旧值 320px 自本条款起作废,不得再使用。

### 7.5 页签最小宽度保底与最大宽度上限(`--tab-min-width` / `--tab-max-width`)
### 7.5 页签最大宽度上限与同比例收缩(`--tab-max-width`)

多页签在页签条内弹性伸缩;页签**不伸展**(`flex: 0 1 auto`),宽度按内容自适应,上限 `--tab-max-width`。收缩下限 `--tab-min-width` 的保底语义为「下限 min(96px, 内容宽)」——短名按实际宽度,不被撑到 96px。页签条可用宽度低于「全部页签保底之和 + 相邻间距」时,页签不再压缩,由页签条横向滚动接管。
多页签在页签条内弹性伸缩;页签**不伸展**(`flex: 0 1 auto`),宽度按内容自适应,上限 `--tab-max-width`;短名按实际内容宽度、长名在最大宽度内以省略号收尾。**窗格变窄时全部页签按可用宽度同比例收缩(`flex-shrink` + `min-width: 0`),不设内容保底、不先截断到保底再滚动**(跨引擎一致)。页签条 `overflow-x: auto` 仅作极端兜底。

| 规范值 | 值 | 用途 |
|---|---|---|
| `--tab-min-width` | 96px | 页签收缩下限(与内容宽取 min);短名按实际宽度,不被撑到 96px |
| `--tab-min-width` | 96px | **已退役**:不再作为收缩下限(保留 token 定义仅作历史注释,组件不引用) |
| `--tab-max-width` | `var(--tab-info-width)`(256px) | 页签最大宽度上限;页签不伸展,超出以省略号收尾 |
| `--tab-strip-tail` | 24px | 页签条尾部保留的空白区;承载空白处拖窗与双击切全屏,不随页签伸缩吃掉 |

取值依据:页签内容最小可读宽度 = 左右内距 20px(`px-2.5`)+ 类型图标 20px(18px 图标 + 2px 右间距)+ 标题两侧间隙 12px(`gap-1.5` × 2)+ 关闭钮约 16px + 标题最短可读约 28px(12px 字号下 2–3 个中文字)≈ 96px。保底被击穿后页签条 `overflow-x-auto` 接管:长标题页签保持 96px 不再收缩,短名页签保持其内容宽度。
取值依据:页签内容最小可读宽度 = 左右内距 20px(`px-2.5`)+ 类型图标 20px(18px 图标 + 2px 右间距)+ 标题两侧间隙 12px(`gap-1.5` × 2)+ 关闭钮约 16px + 标题最短可读约 28px(12px 字号下 2–3 个中文字)≈ 96px。`--tab-min-width` 的 96px 保底自本条款起退役:收缩改由 `flex-shrink` 同比例分配(每项收缩量 ∝ 内容宽),不设保底,避免长名缩到保底即停、短名完全不缩。

本条款取代旧「页签标题最大显示宽度 120px」口径;120px 固定上限仍退役,现以 `--tab-max-width`(引用 `--tab-info-width`,256px)作为**弹性上限**重新存在——页签不伸展,宽度按内容自适应并被该上限钳制(见 [decisions.md](./decisions.md) 最新行)。

Expand Down
87 changes: 65 additions & 22 deletions e2e/tab-selection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect, type Page } from "@playwright/test";
import { mkdirSync } from "fs";
import { mkdirSync, writeFileSync } from "fs";

const APP_URL = process.env.BIAOYUE_E2E_URL ?? "http://localhost:1424";
const ARTIFACT_DIR = ".artifacts/1231";
const ARTIFACT_DIR = ".artifacts/1843";

/**
* 等长标题页签的宽度容差。激活页签走 `font-medium`(字重更宽),
Expand Down Expand Up @@ -122,11 +122,31 @@ function spread(widths: number[]): number {
return Math.max(...widths) - Math.min(...widths);
}

type CoverageState = {
state: string;
screenshot: string;
assertion: "passed";
detail: string;
};

test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs-surface 1.1 / #1231)", () => {
const coverage: CoverageState[] = [];

test.beforeAll(() => {
mkdirSync(ARTIFACT_DIR, { recursive: true });
});

test.afterAll(() => {
writeFileSync(
`${ARTIFACT_DIR}/state-coverage.json`,
JSON.stringify(
{ task: "1843-proportional-shrink", states: coverage },
null,
2,
),
);
});

test("相邻页签间距保持 32px,标题与关闭图标之间压缩(#1138)", async ({
page,
}) => {
Expand Down Expand Up @@ -215,24 +235,22 @@ test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs
expect(m.widths[0]).toBeLessThan(m.tabMaxWidth);

await page.screenshot({ path: `${ARTIFACT_DIR}/01-title-ellipsis.png` });
coverage.push({
state: "01-long-cap-ellipsis",
screenshot: "01-title-ellipsis.png",
assertion: "passed",
detail: `长名省略号+上限钳制:长页签 ${m.widths[1].toFixed(1)}px ≈ tabMaxWidth ${m.tabMaxWidth}px,短页签 ${m.widths[0].toFixed(1)}px`,
});
});

test("保底被击穿后页签条才横向滚动(A-1.5)", async ({ page }) => {
test("窗格变窄时全部页签同比例收缩(#1843)", async ({ page }) => {
await boot(page);
const long = "very-long-tab-title-abcdefghijklmnopqrstuvwxyz-";
for (let i = 0; i < 8; i += 1) {
await openFile(page, `/tmp/1053/${long}${i}.md`);
}

const strip = page.locator(".tab-strip").first();
const minWidth = await page.evaluate(() =>
parseFloat(
getComputedStyle(document.documentElement).getPropertyValue(
"--tab-min-width",
),
),
);
expect(minWidth).toBeGreaterThan(0);

await page.setViewportSize({ width: 1600, height: 800 });
await expect
Expand All @@ -244,21 +262,28 @@ test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs
for (const w of wide.widths) {
// 长标题页签先被 --tab-max-width 钳住,再随可用宽度收缩;始终不超上限
expect(w).toBeLessThanOrEqual(wide.tabMaxWidth + 1);
expect(w).toBeGreaterThan(minWidth + 8);
}

await page.setViewportSize({ width: 700, height: 800 });
// 收缩到适应:无溢出、无横向滚动
await expect
.poll(async () => strip.evaluate((el) => el.scrollWidth > el.clientWidth))
.poll(async () =>
strip.evaluate((el) => el.scrollWidth <= el.clientWidth + 1),
)
.toBe(true);
const narrowWidths = await page.evaluate(() =>
Array.from(
document.querySelectorAll<HTMLElement>(".tab-strip [data-tab-id]"),
).map((el) => el.getBoundingClientRect().width),
);
// 长标题的 max-content > 96px,保底仍为 96px
for (const w of narrowWidths) {
expect(Math.abs(w - minWidth)).toBeLessThanOrEqual(1);
const narrow = await readStrip(page);
// 每个页签都变窄(同比例收缩,不是只有长名缩、短名不缩)
for (let i = 0; i < narrow.widths.length; i += 1) {
expect(narrow.widths[i]).toBeLessThan(wide.widths[i]);
}
// 等长标题页签收缩后仍近似等宽(激活页签 font-medium 有几像素差)
expect(spread(narrow.widths)).toBeLessThanOrEqual(EQUAL_WIDTH_TOLERANCE);
// 相邻页签不互相覆盖,间距保持 32px
expect(narrow.gap).toBe("32px");
for (let i = 1; i < narrow.lefts.length; i += 1) {
expect(narrow.lefts[i]).toBeGreaterThanOrEqual(
narrow.rights[i - 1] - 0.5,
);
}

const boxed = await page
Expand All @@ -280,7 +305,13 @@ test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs
expect(boxed.iconBottom).toBeLessThanOrEqual(boxed.stripHeight);

await page.screenshot({
path: `${ARTIFACT_DIR}/03-strip-min-width-scroll.png`,
path: `${ARTIFACT_DIR}/03-narrow-proportional-shrink.png`,
});
coverage.push({
state: "04-narrow-proportional-shrink",
screenshot: "03-narrow-proportional-shrink.png",
assertion: "passed",
detail: `窄视口同比例收缩:宽 [${wide.widths.map((w) => w.toFixed(0)).join(",")}] → 窄 [${narrow.widths.map((w) => w.toFixed(0)).join(",")}],scrollWidth ${narrow.scrollWidth} ≤ clientWidth ${narrow.clientWidth}`,
});
});

Expand Down Expand Up @@ -334,6 +365,12 @@ test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs
expect(m.widths[0]).toBeLessThan(m.tabMinWidth);

await page.screenshot({ path: `${ARTIFACT_DIR}/06-single-short-tab.png` });
coverage.push({
state: "02-short-actual",
screenshot: "06-single-short-tab.png",
assertion: "passed",
detail: `短名按实际宽度:页签 ${m.widths[0].toFixed(1)}px < tabMinWidth ${m.tabMinWidth}px(未被撑到保底)`,
});
});

test("短名按实际宽度显示:短名页签窄于长名页签(#1231)", async ({
Expand All @@ -356,6 +393,12 @@ test.describe("页签弹性伸缩与间距(tab-title-info-surface / shell-tabs
expect(Math.abs(m.widths[1] - m.tabMaxWidth)).toBeLessThanOrEqual(1);

await page.screenshot({ path: `${ARTIFACT_DIR}/07-short-vs-long.png` });
coverage.push({
state: "03-not-fill",
screenshot: "07-short-vs-long.png",
assertion: "passed",
detail: `不铺满/不伸展:短 ${m.widths[0].toFixed(1)}px < 长 ${m.widths[1].toFixed(1)}px ≈ 上限 ${m.tabMaxWidth}px`,
});
});

test("两个等长页签在窄视口等比收缩到等宽(#1231)", async ({ page }) => {
Expand Down
20 changes: 10 additions & 10 deletions openspec/specs/application-shell/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ application-shell 域定义标月桌面端的整体界面布局决策与空状

页签标题 SHALL 在双击后进入行内改名;输入框宽度 SHALL 为原宽度的 1.5 倍(`24ch`),回车提交、Esc 取消,路径 SHALL 不变。

**页签标题显示与间距**:页签 SHALL 弹性布局——页签 SHALL NOT 主动伸展填满页签条,单页签与短标题页签按内容实际宽度显示,页签宽度上限取 `--tab-max-width`(与页签信息窗 `--tab-info-width` 同宽);多页签超出页签条可用宽度时按可用宽度等比伸缩(flex 分配),最小宽度保底仅约束收缩(下限 `min(96px, 页签内容宽)`);标题在伸缩后的可用宽度内 SHALL 以 `text-overflow: ellipsis` 收尾、单行 `white-space: nowrap`,SHALL NOT 换行,SHALL NOT 使用 `-webkit-line-clamp`。完整文件名 SHALL 在页签名信息窗内换行可读(见 navigation 域「页签条与格头」)。仅当页签条可用宽度不足以容纳全部页签的最小宽度保底时,页签条 SHALL 横向滚动,SHALL NOT 压缩页签到不可读或溢出容器。相邻页签之间的间距 SHALL 为 **32px**(容差 ±2px);单个页签内标题右缘到关闭按钮左缘的水平间距 SHALL 不超过 **6px**。
**页签标题显示与间距**:页签 SHALL 弹性布局——页签 SHALL NOT 伸展(`flex: 0 1 auto`),最大宽度取 `--tab-max-width`(与页签信息窗 `--tab-info-width` 同宽);短名按实际内容宽度、长名在最大宽度内以省略号收尾;**窗格变窄时全部页签 SHALL 按可用宽度同比例收缩(`flex-shrink`),不设内容保底、不先截断到保底再滚动**(`min-width: 0`,跨引擎一致)。标题在收缩后的可用宽度内 SHALL 以 `text-overflow: ellipsis` 收尾、单行 `white-space: nowrap`,SHALL NOT 换行,SHALL NOT 使用 `-webkit-line-clamp`。完整文件名 SHALL 在页签名信息窗内换行可读(见 navigation 域「页签条与格头」)。页签条 `overflow-x: auto` 仅作极端兜底,本模型下 SHALL NOT 因保底被击穿而先行横向滚动,SHALL NOT 压缩页签到不可读或溢出容器。相邻页签之间的间距 SHALL 为 **32px**(容差 ±2px);单个页签内标题右缘到关闭按钮左缘的水平间距 SHALL 不超过 **6px**。

#### Scenario: 改名输入框加长

Expand All @@ -110,17 +110,17 @@ application-shell 域定义标月桌面端的整体界面布局决策与空状

#### Scenario: 短标题按实际长度显示

> 场景标题沿用旧名以保持条款可追溯;自本 change 起页签弹性伸缩,短标题所在页签按分配宽度显示(可长于文本实际宽度),不再固定按文本实际长度。
> 场景标题沿用旧名以保持条款可追溯;自本 change 起页签不伸展,短标题所在页签按内容实际宽度显示,不被撑到分配宽度或保底。

- **WHEN** 页签标题的自然宽度小于其分配到的页签宽度
- **THEN** 该页签的渲染宽度 SHALL 等于其分配宽度(可大于文本实际宽度),标题在分配宽度内以省略号收尾,SHALL NOT 被固定上限截断
- **WHEN** 页签标题的自然宽度小于最大宽度
- **THEN** 该页签的渲染宽度 SHALL 等于其内容实际宽度(不被伸展),标题在最大宽度内以省略号收尾,SHALL NOT 被固定上限截断

#### Scenario: 页签条横向滚动

> 场景标题沿用旧名;自本 change 起仅当可用宽度不足以容纳全部页签的最小宽度保底时才横向滚动。
> 场景标题沿用旧名;自本 change 起页签不设内容保底,变窄时同比例收缩,横向滚动仅作极端兜底。

- **WHEN** 页签条可用宽度不足以容纳全部页签的最小宽度保底
- **THEN** 页签条 SHALL 可横向滚动,页签宽度 SHALL 保持其最小宽度保底,SHALL NOT 压缩到不可读或溢出容器
- **WHEN** 页签条可用宽度不足以容纳全部页签(极端窄窗)
- **THEN** 页签条 SHALL 可横向滚动,SHALL NOT 压缩到不可读或溢出容器

#### Scenario: 页签间距 32px

Expand All @@ -132,12 +132,12 @@ application-shell 域定义标月桌面端的整体界面布局决策与空状
#### Scenario: 窗格变窄时页签等比收缩

- **WHEN** 用户在多页签栏目内收窄窗格(或窗口)使页签条可用宽度变小
- **THEN** 各页签宽度 SHALL 按可用宽度同比缩小(收缩比例一致),相邻页签间距 SHALL 保持 32px,页签之间 SHALL NOT 互相覆盖,页签条 SHALL NOT 溢出容器
- **THEN** 全部页签宽度 SHALL 按可用宽度同比例缩小(每个页签都变窄、收缩比例一致),相邻页签间距 SHALL 保持 32px,页签之间 SHALL NOT 互相覆盖,页签条 SHALL NOT 溢出容器或先行横向滚动

#### Scenario: 短页签按实际宽度显示

- **WHEN** 页签标题内容宽小于收缩保底
- **THEN** 页签 SHALL 按内容实际宽度显示,SHALL NOT 被撑到保底宽
- **WHEN** 页签标题内容宽小于最大宽度
- **THEN** 页签 SHALL 按内容实际宽度显示,SHALL NOT 被撑到保底宽或伸展

#### Scenario: 单页签不顶满页签条

Expand Down
Loading
Loading