Skip to content

Commit 4c77c3a

Browse files
UI: fix chat context notice icon sizing (openclaw#45533)
* UI: fix chat context notice icon sizing * Update ui/src/ui/views/chat.browser.test.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> * UI: tighten chat context notice regression test --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent e8c300c commit 4c77c3a

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

ui/src/styles/chat/layout.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,37 @@
146146
flex-shrink: 0;
147147
}
148148

149+
/* Context usage warning pill */
150+
.context-notice {
151+
align-self: center;
152+
display: inline-flex;
153+
align-items: center;
154+
gap: 8px;
155+
padding: 7px 14px;
156+
margin: 0 auto 8px;
157+
border-radius: 999px;
158+
border: 1px solid color-mix(in srgb, var(--ctx-color, #d97706) 35%, transparent);
159+
background: var(--ctx-bg, rgba(217, 119, 6, 0.12));
160+
color: var(--ctx-color, #d97706);
161+
font-size: 13px;
162+
line-height: 1.2;
163+
white-space: nowrap;
164+
user-select: none;
165+
animation: fade-in 0.2s var(--ease-out);
166+
}
167+
168+
.context-notice__icon {
169+
width: 16px;
170+
height: 16px;
171+
flex-shrink: 0;
172+
stroke: currentColor;
173+
}
174+
175+
.context-notice__detail {
176+
color: color-mix(in srgb, currentColor 72%, var(--muted));
177+
font-variant-numeric: tabular-nums;
178+
}
179+
149180
/* Chat compose - sticky at bottom */
150181
.chat-compose {
151182
position: sticky;
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { render } from "lit";
2+
import { afterEach, describe, expect, it } from "vitest";
3+
import "../../styles.css";
4+
import { renderChat, type ChatProps } from "./chat.ts";
5+
6+
function createProps(overrides: Partial<ChatProps> = {}): ChatProps {
7+
return {
8+
sessionKey: "main",
9+
onSessionKeyChange: () => undefined,
10+
thinkingLevel: null,
11+
showThinking: false,
12+
loading: false,
13+
sending: false,
14+
canAbort: false,
15+
compactionStatus: null,
16+
fallbackStatus: null,
17+
messages: [],
18+
toolMessages: [],
19+
streamSegments: [],
20+
stream: null,
21+
streamStartedAt: null,
22+
assistantAvatarUrl: null,
23+
draft: "",
24+
queue: [],
25+
connected: true,
26+
canSend: true,
27+
disabledReason: null,
28+
error: null,
29+
sessions: {
30+
ts: 0,
31+
path: "",
32+
count: 1,
33+
defaults: { model: "gpt-5", contextTokens: null },
34+
sessions: [
35+
{
36+
key: "main",
37+
kind: "direct",
38+
updatedAt: null,
39+
inputTokens: 3_800,
40+
contextTokens: 4_000,
41+
},
42+
],
43+
},
44+
focusMode: false,
45+
assistantName: "OpenClaw",
46+
assistantAvatar: null,
47+
onRefresh: () => undefined,
48+
onToggleFocusMode: () => undefined,
49+
onDraftChange: () => undefined,
50+
onSend: () => undefined,
51+
onQueueRemove: () => undefined,
52+
onNewSession: () => undefined,
53+
agentsList: null,
54+
currentAgentId: "",
55+
onAgentChange: () => undefined,
56+
...overrides,
57+
};
58+
}
59+
60+
describe("chat context notice", () => {
61+
afterEach(() => {
62+
document.body.innerHTML = "";
63+
});
64+
65+
it("keeps the warning icon badge-sized", async () => {
66+
const container = document.createElement("div");
67+
document.body.append(container);
68+
render(renderChat(createProps()), container);
69+
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
70+
71+
const icon = container.querySelector<SVGElement>(".context-notice__icon");
72+
expect(icon).not.toBeNull();
73+
if (!icon) {
74+
return;
75+
}
76+
77+
const iconStyle = getComputedStyle(icon);
78+
expect(iconStyle.width).toBe("16px");
79+
expect(iconStyle.height).toBe("16px");
80+
expect(icon.getBoundingClientRect().width).toBeLessThan(24);
81+
});
82+
});

0 commit comments

Comments
 (0)