diff --git a/scripts/check-thinking-ui.mjs b/scripts/check-thinking-ui.mjs index c1c5db4ab8..63bab85191 100644 --- a/scripts/check-thinking-ui.mjs +++ b/scripts/check-thinking-ui.mjs @@ -111,21 +111,28 @@ try { await trigger.click(); const pop = page.locator('.seat-pop'); await pop.waitFor({ timeout: 8000 }); - const stops = pop.locator('.thinking-stop'); - ok(await stops.count() === 4, '滑块应只有声明的 4 个档位(实际 ' + await stops.count() + ')'); - const ticks = await pop.locator('.thinking-tick').allInnerTexts(); - ok(JSON.stringify(ticks) === JSON.stringify(['关闭', '低', '中', '高']), '刻度应是声明的档位集合(实际 ' + JSON.stringify(ticks) + ')'); - ok(!ticks.includes('最少'), '不能出现未声明的「最少」档'); + const steps = pop.locator('.thinking-step'); + ok(await steps.count() === 4, '档位条应有声明的 4 段(实际 ' + await steps.count() + ')'); + const names = await pop.locator('.thinking-step-name').allInnerTexts(); + ok(JSON.stringify(names) === JSON.stringify(['关闭', '低', '中', '高']), '分段名应是声明的档位集合(实际 ' + JSON.stringify(names) + ')'); + ok(!names.includes('最少'), '不能出现未声明的「最少」档'); + // 分段进度条:没有可拖的把手,段与段等宽(「拖动」这个交互本身不存在) + ok(await pop.locator('.thinking-stop, .thinking-dot, .thinking-fill, .thinking-slider').count() === 0, '不应再有滑杆/把手节点'); + const widths = await pop.locator('.thinking-step').evaluateAll(els => els.map(el => Math.round(el.getBoundingClientRect().width))); + ok(new Set(widths).size === 1, '各段应等宽(实际 ' + JSON.stringify(widths) + ')'); // 设计图要求:大号档位名 + 其下带箭头的模型行,两者都在同一个浮层里 ok((await pop.locator('.thinking-level').innerText()).trim() === '中', '浮层应大字显示当前档位'); ok(/gpt-5\.1/.test(await pop.locator('.seat-modelrow').innerText()), '档位下方应是可点的模型行'); + // 顶部闪电已按要求移除(触发器与浮层都不留) + ok(await pop.locator('.thinking-bolt').count() === 0, '浮层不应再有闪电图标'); + ok(await page.locator('.seat-trigger .seat-bolt').count() === 0, '触发器不应再有闪电图标'); // 底部必须如实说出会发什么,而不是只写「更聪明」 const payload = await pop.locator('.thinking-payload').innerText(); ok(/reasoning_effort: medium/.test(payload), '应显示实际发送的参数(实际 ' + JSON.stringify(payload) + ')'); await page.screenshot({ path: path.join(ROOT, '.thinking-ui-pop.png') }); // 3) 点最高档 → 写入 settings.json,触发器跟着变 - await stops.nth(3).click(); + await steps.nth(3).click(); await page.waitForTimeout(400); ok(readSettings().activeThinking === 'high', '选高后应写入 activeThinking=high(实际 ' + JSON.stringify(readSettings().activeThinking) + ')'); await trigger.waitFor(); @@ -134,18 +141,21 @@ try { ok(/reasoning_effort: high/.test(payloadHigh), '高对应 reasoning_effort: high(实际 ' + JSON.stringify(payloadHigh) + ')'); await page.keyboard.press('Escape'); - // 4) 键盘可达:聚焦滑杆后按 Home/ArrowRight 也能改档 + // 4) 键盘可达:聚焦档位条后按 Home/ArrowRight 也能改档 // 注意必须重新打开浮层——上一步按 Escape 已经把它卸载,对已卸载节点 focus() 不会生效。 await trigger.click(); await page.locator('.seat-pop').waitFor({ timeout: 8000 }); - const slider = page.locator('.seat-pop .thinking-slider'); - await slider.focus(); + const bar = page.locator('.seat-pop .thinking-steps'); + await bar.focus(); await page.keyboard.press('Home'); await page.waitForTimeout(300); ok(readSettings().activeThinking === 'off', 'Home 应选中第一档关闭(实际 ' + JSON.stringify(readSettings().activeThinking) + ')'); await page.keyboard.press('ArrowRight'); await page.waitForTimeout(400); ok(readSettings().activeThinking === 'low', 'ArrowRight 应前进到下一档(实际 ' + JSON.stringify(readSettings().activeThinking) + ')'); + await page.keyboard.press('End'); + await page.waitForTimeout(400); + ok(readSettings().activeThinking === 'high', 'End 应跳到最后一档(实际 ' + JSON.stringify(readSettings().activeThinking) + ')'); await page.keyboard.press('Escape'); // 4b) 模型行是真实入口:从座位里钻取到模型目录并切换模型(不是只显示个名字) @@ -160,7 +170,7 @@ try { // 5) 切到没有声明的模型:强度那部分必须消失,不能留一个拖了没反应的滑杆 // 座位本身要留着——它仍然是选模型的唯一入口。 ok(await page.locator('.seat-trigger').count() === 1, '未声明档位的模型仍应有模型座位'); - ok(await page.locator('.thinking-slider').count() === 0, '未声明档位时不应渲染滑杆'); + ok(await page.locator('.thinking-steps').count() === 0, '未声明档位时不应渲染档位条'); await page.locator('.seat-trigger').click(); await page.locator('.seat-pop').waitFor({ timeout: 8000 }); ok(await page.locator('.seat-pop .thinking-level').count() === 0, '未声明档位时浮层不应有大号档位名'); diff --git a/ui/src/app.css b/ui/src/app.css index d29220aab6..6cf7d97746 100644 --- a/ui/src/app.css +++ b/ui/src/app.css @@ -240,23 +240,23 @@ kbd { font-family: var(--default-font-family); font-size: 10px; font-weight: 400 .composer-seat > div { min-width: 0 !important; } /* 触发器:闪电 + 模型名 + 当前档位 + 箭头,读作「哪个模型 · 多用力」。 */ -.seat-trigger { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 32px; padding: 0 8px 0 10px; border: 1px solid transparent; border-radius: 9px; background: var(--hover); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; white-space: nowrap; } +.seat-trigger { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 9px; background: var(--hover); color: var(--muted); font-size: 13px; line-height: 1; cursor: pointer; white-space: nowrap; } .seat-trigger:hover { background: var(--line); color: var(--ink); } .seat-trigger:focus-visible { outline: 2px solid var(--accent-9); outline-offset: 2px; } .seat-trigger:disabled { cursor: default; opacity: .6; } .seat-trigger svg { flex: 0 0 auto; } -.seat-bolt { color: var(--brand-text); } .seat-model { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* 强度先被饿死:名字比档位重要,和 DSH 的 .triggerEffort 收缩优先级一致 */ .seat-level { flex-shrink: 1000; min-width: 0; overflow: hidden; color: var(--subtle); text-overflow: ellipsis; } .seat-chevron { color: var(--subtle); } -/* 浮层:对齐设计图的信息层次——图标行、大号档位名、模型行(带箭头)、分段滑杆、刻度、实际发出的参数 */ +/* 浮层:对齐设计图的信息层次——大号档位名(右侧复位)、模型行(带箭头)、分段进度条、实际发出的参数 */ .seat-pop { padding: 14px 16px 12px; } -.seat-pop .thinking-bolt { display: inline-flex; align-items: center; color: var(--brand-text); } -.thinking-reset { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--subtle); cursor: pointer; } +.seat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; } +.thinking-reset { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--subtle); cursor: pointer; } .thinking-reset:hover { background: var(--hover); color: var(--ink); } -.thinking-level { margin-top: 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: var(--brand-text); line-height: 1.25; } +.thinking-level { min-width: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: var(--brand-text); line-height: 1.25; } +.thinking-level.muted { font-size: 15px; font-weight: 500; color: var(--muted); } /* 模型行:设计图里档位名下方那行「模型名 + 箭头」,点它钻取到模型目录 */ .seat-modelrow { display: flex; align-items: center; gap: 4px; max-width: 100%; margin-top: 2px; padding: 2px 4px 2px 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; } @@ -282,22 +282,21 @@ kbd { font-family: var(--default-font-family); font-size: 10px; font-weight: 400 .seat-check { flex: 0 0 auto; margin-left: auto; color: var(--brand-text); } .seat-empty { padding: 8px 6px; } -.thinking-slider { position: relative; height: 26px; margin: 16px 8px 0; cursor: pointer; } -.thinking-slider:focus-visible { outline: 2px solid var(--accent-9); outline-offset: 4px; border-radius: 6px; } -.thinking-track { position: absolute; top: 50%; left: 0; right: 0; height: 3px; margin-top: -1.5px; border-radius: 2px; background: var(--line-strong); } -.thinking-fill { display: block; height: 100%; border-radius: inherit; background: var(--brand-text); transition: width .14s ease; } -.thinking-stops { position: absolute; inset: 0; } -/* 每个档位是一个真正的按钮:鼠标点,键盘左右箭头走,命中区比圆点大 */ -.thinking-stop { position: absolute; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; } -.thinking-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); transition: width .14s ease, height .14s ease, background .14s ease; } -.thinking-stop.passed .thinking-dot { background: var(--brand-text); } -.thinking-stop.on .thinking-dot { width: 14px; height: 14px; background: var(--color-panel-solid); border: 3px solid var(--brand-text); box-shadow: 0 1px 4px rgba(0,0,0,.18); } -.thinking-stop:focus-visible { outline: 2px solid var(--accent-9); outline-offset: 1px; } - -.thinking-ticks { display: flex; justify-content: space-between; margin: 4px 0 0; } -.thinking-tick { flex: 1 1 0; text-align: center; font-size: 10px; color: var(--subtle); } -.thinking-tick:first-child { text-align: left; } .thinking-tick:last-child { text-align: right; } -.thinking-tick.on { color: var(--ink); } +/* 档位条:一张 N 段进度条,段与段之间留缝,每一段就是一个档位。 + 没有把手、没有「拖到中间」的可能;已过的段用淡色表示进度,当前段实色。 */ +.thinking-steps { display: flex; gap: 4px; margin: 14px 0 0; border-radius: 8px; } +.thinking-steps:focus-visible { outline: 2px solid var(--accent-9); outline-offset: 4px; } +.thinking-step { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 7px; padding: 2px 0; border: 0; background: transparent; color: var(--subtle); font: inherit; cursor: pointer; } +.thinking-step-bar { display: block; height: 6px; border-radius: 3px; background: var(--line-strong); transition: background .14s ease, opacity .14s ease; } +.thinking-step-name { font-size: 10px; line-height: 1.2; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.thinking-step:not(.on):not(.done):hover .thinking-step-bar { background: var(--muted); } +/* 已过的段是「进度」,当前段是「档位」:前者淡、后者实,一眼能看出停在第几档 */ +.thinking-step.done .thinking-step-bar { background: var(--brand-text); opacity: .4; } +.thinking-step.done .thinking-step-name { color: var(--muted); } +.thinking-step.on .thinking-step-bar { background: var(--brand-text); } +.thinking-step.on .thinking-step-name { color: var(--ink); font-weight: 500; } +.thinking-step:focus-visible { outline: none; } +.thinking-step:focus-visible .thinking-step-bar { outline: 2px solid var(--accent-9); outline-offset: 2px; } .thinking-payload { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-family: var(--code-font-family); font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; } .composer-mode { min-width: 0; flex: 0 0 auto; } diff --git a/ui/src/thinking-picker.jsx b/ui/src/thinking-picker.jsx index d2acab6f86..fe635b03d1 100644 --- a/ui/src/thinking-picker.jsx +++ b/ui/src/thinking-picker.jsx @@ -8,13 +8,16 @@ // · 没有声明推理等级的模型不渲染强度那一块(DSH 里 reasoning === undefined 时该行整个不出现), // 而不是留一个拖了没反应的滑杆。 // -// 视觉照产品给的设计图:顶部闪电 + 复位,中间大号档位名,其下模型行(带箭头), -// 再往下是离散分段滑杆与档位刻度,底部如实写出这一档会放进请求体的参数。 +// 视觉照产品给的设计图:大号档位名(右侧复位),其下模型行(带箭头), +// 再往下是分段进度条与档位刻度,底部如实写出这一档会放进请求体的参数。 +// 设计图顶部的闪电图标已按要求去掉;触发器上也不留。 // -// 滑杆自己实现,不引 @radix-ui/react-slider:它只是 Radix Themes 的传递依赖, -// 直接 import 会在依赖提升变化时突然找不到,而这个控件的语义(离散档位)也不需要完整 slider。 -import React, { useEffect, useId, useMemo, useRef, useState } from 'react'; -import { Flex, Popover, Text } from '@radix-ui/themes'; +// 档位是「分段进度条」而不是滑杆:条被切成与档位一一对应的等宽小块,点哪块就跳到哪档, +// 没有可拖的把手,也就不会有「拖到两档之间」这种不存在的状态。 +// 自己实现而不引 @radix-ui/react-slider:它只是 Radix Themes 的传递依赖, +// 直接 import 会在依赖提升变化时突然找不到,而这里要的恰恰不是 slider 语义。 +import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { Popover, Text } from '@radix-ui/themes'; import { Icon } from './kit.jsx'; import { levelLabel, payloadLabel, normalizeThinkingLevels } from '../../sidecar/thinking.mjs'; @@ -64,7 +67,6 @@ export function ModelSeat({ return } - - {hasEffort && {shown}} + } )} - - - - ; + return
+ {list.map((id, index) => )} +
; }