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
8 changes: 8 additions & 0 deletions crates/agent-gui/test/chat/context-usage.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ test("context usage ring stays vertically centered in the shared composer", () =
assert.doesNotMatch(chatComposerBarSource, /className="absolute bottom-11 right-3 z-20"/);
});

test("composer editor row reserves the right control rail so the scrollbar clears the ring", () => {
// 让位必须做在编辑器外层容器上:padding 不移动滚动条,编辑器自带 pr-8 时
// 那条 6px 滚动轨会压在用量环/展开图标上(right-3 + w-8 的 44px 轨道)。
assert.match(chatComposerBarSource, /"relative flex flex-1 pl-4 pr-12"/);
assert.doesNotMatch(chatComposerBarSource, /"relative flex flex-1 px-4"/);
assert.doesNotMatch(chatComposerBarSource, /"px-0 py-0 pr-8"/);
});

test("contextUsageRatio guards degenerate inputs", () => {
assert.equal(contextUsageRatio(100_000, 200_000), 0.5);
assert.equal(contextUsageRatio(undefined, 200_000), 0);
Expand Down
15 changes: 12 additions & 3 deletions crates/agent-ui/src/pages/chat/ChatComposerBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,17 @@ export const ChatComposerBar = memo(function ChatComposerBar(props: ChatComposer

{/* 常驻 flex-1:动画把卡片钳在中间高度时由本区吸收伸缩,工具栏才能
全程贴住卡片底边。min-h-0 只在展开态加——折叠态靠自动最小高度
(= 编辑器钳制高) 撑起卡片的固有高度,加了会塌缩。 */}
(= 编辑器钳制高) 撑起卡片的固有高度,加了会塌缩。

pr-12 让出右侧控制列:展开/用量环/发送都是 right-3 + w-8,占据卡片
右缘 44px 宽的竖直轨道。让位必须做在本容器上,**不能只给编辑器加
pr-8**——padding 不改变滚动条位置(滚动条恒贴 border box 右缘),
只挡文字不挡滚动条,溢出时那条 6px 轨会直接压在环与展开图标上。
收窄编辑器 border box 才能把滚动条一并推到轨道左侧;48px = 44 轨道
+ 4px 间隙,文本可用宽度与原先 px-4 + 编辑器 pr-8 完全一致。 */}
<div
className={cn(
"relative flex flex-1 px-4",
"relative flex flex-1 pl-4 pr-12",
pendingUploadedFiles.length > 0 ? "pt-1.5" : "pt-3.5",
isComposerExpanded && "min-h-0",
)}
Expand All @@ -970,7 +977,9 @@ export const ChatComposerBar = memo(function ChatComposerBar(props: ChatComposer
workdir={workdir}
enabledSkills={enabledSkills}
className={cn(
"px-0 py-0 pr-8",
// 右让位由外层容器 pr-12 统一承担(见上),此处不再补 pr——
// 编辑器自身的右内距只会把文字推开、留下滚动条压在控制列上。
"px-0 py-0",
isComposerExpanded &&
(surface === "desktop" ? "h-full max-h-none" : "h-full! max-h-none!"),
)}
Expand Down
Loading