Skip to content

Commit 3e092d0

Browse files
committed
refactor(ui): 调整多组件样式与布局优化
- 将 Messages 组件移动至 App.tsx 以优化界面结构 - ContextMeter 中调整字体大小,统一文本样式细节 - 取消 markdown 代码块内边距,改善视觉效果 - PlanRenderer 优化缩进及元素间距,改善文本换行表现 - SessionList 中添加按钮点击事件以控制抽屉状态 - 各类型气泡组件微调顶部间距,提升对齐一致性 - ThinkingLiveBubble 添加响应式宽度限制,居中显示 - ToolBubble 中引入 Tooltip 组件,为参数文本添加悬浮提示展示 - 移除 Messages.tsx 内部分 console.log 调试信息
1 parent b145755 commit 3e092d0

10 files changed

Lines changed: 42 additions & 29 deletions

File tree

packages/vscode-ide-companion/src/webview/App.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ export default function App() {
1616
onSelectSession={actions.selectSession}
1717
onCreateNewSession={actions.createNewSession}
1818
/>
19+
<Messages
20+
messages={state.messages}
21+
loading={state.loading}
22+
llmStreamProgress={state.llmStreamProgress}
23+
processes={state.processes}
24+
onEditMessage={actions.editMessage}
25+
/>
1926
<PermissionPrompt
2027
askPermissions={state.askPermissions}
2128
sessionStatus={state.activeSessionStatus}
@@ -27,13 +34,6 @@ export default function App() {
2734
activeSessionId={state.activeSessionId}
2835
onInterrupt={actions.interrupt}
2936
/>
30-
<Messages
31-
messages={state.messages}
32-
loading={state.loading}
33-
llmStreamProgress={state.llmStreamProgress}
34-
processes={state.processes}
35-
onEditMessage={actions.editMessage}
36-
/>
3737
{state.loading && (
3838
<ThinkingLiveBubble
3939
llmStreamProgress={state.llmStreamProgress}

packages/vscode-ide-companion/src/webview/components/ContextMeter.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ export default function ContextMeter({ tokenTelemetry }: ContextMeterProps) {
3030
</InputGroupButton>
3131
</HoverCardTrigger>
3232
<HoverCardContent className="flex w-xs flex-col gap-5">
33-
<div className="font-semibold text-lg text-center">Context Window</div>
33+
<div className="font-semibold text-[16px] text-center">Context Window</div>
3434
<Field className="w-full max-w-xs">
3535
<FieldLabel htmlFor="progress-upload" className="flex items-end">
3636
<span className="text-primary text-xl font-bold">{percent}%</span>
37-
<span className="text-muted-foreground">used</span>
37+
<span className="text-xs text-muted-foreground">used</span>
3838
</FieldLabel>
3939
<Progress value={percent} id="progress-upload" />
4040
</Field>
4141
<div className="space-y-1">
4242
<div className="flex justify-between">
43-
<span className="text-muted-foreground">Model</span>
43+
<span className="text-xs text-muted-foreground">Model</span>
4444
<span className="text-primary">{tokenTelemetry?.model || "unknown"}</span>
4545
</div>
4646
<div className="flex justify-between">
47-
<span className="text-muted-foreground">Thinking</span>
47+
<span className="text-xs text-muted-foreground">Thinking</span>
4848
<span className="text-primary">{tokenTelemetry?.thinkingEnabled ? "true" : "false"}</span>
4949
</div>
5050
<div className="flex justify-between">
51-
<span className="text-muted-foreground">Effort</span>
51+
<span className="text-xs text-muted-foreground">Effort</span>
5252
<span className="text-primary">{tokenTelemetry?.reasoningEffort || "max"}</span>
5353
</div>
5454
<div className="flex justify-between">
55-
<span className="text-muted-foreground">Active Tokens</span>
55+
<span className="text-xs text-muted-foreground">Active Tokens</span>
5656
<span className="text-primary">{formatTokenCount(activeTokens)}</span>
5757
</div>
5858
</div>
@@ -63,7 +63,7 @@ export default function ContextMeter({ tokenTelemetry }: ContextMeterProps) {
6363
<div className="font-semibold text-muted-foreground">Session Usage</div>
6464
{(usedRows || []).map(([key, value]) => (
6565
<div className="flex justify-between" key={key}>
66-
<span className="text-muted-foreground">{toTitleCase(formatUsageFieldLabel(key))}</span>
66+
<span className="text-xs text-muted-foreground">{toTitleCase(formatUsageFieldLabel(key))}</span>
6767
<span className="text-primary">{formatTokenCount(value)}</span>
6868
</div>
6969
))}

packages/vscode-ide-companion/src/webview/components/Messages.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export default function Messages({ messages, loading, llmStreamProgress, process
2323
console.log("processes: ", processes);
2424

2525
useEffect(() => {
26-
console.log("messages:", JSON.stringify(messages));
2726
bottomRef.current?.scrollIntoView({ behavior: "smooth" });
2827
}, [messages, loading]);
2928

@@ -33,7 +32,7 @@ export default function Messages({ messages, loading, llmStreamProgress, process
3332
{messages.map((msg, index) => {
3433
const prevMsg = index > 0 ? messages[index - 1] : null;
3534
const shouldConnect = prevMsg ? prevMsg.role !== "user" && msg.role !== "user" : false;
36-
console.log(`Rendering message ${index}:`, JSON.stringify(msg));
35+
3736
switch (msg.role) {
3837
case "user":
3938
return (

packages/vscode-ide-companion/src/webview/components/PlanRenderer.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ export default function PlanRenderer({ plan }: PlanRendererProps) {
6868
: "text-muted-foreground";
6969

7070
return (
71-
<div key={i} className="pl-2">
72-
<div className="flex items-center gap-2 py-0.5" style={{ paddingLeft: `${indent * 16}px` }}>
73-
<span className={`size-4 font-mono text-xs ${colorClass}`}>{label || " "}</span>
74-
<div className="break-normal text-nowrap w-auto truncate flex-1">
75-
<span dangerouslySetInnerHTML={{ __html: toInlineHtml(taskMatch[3].trim()) }} />
76-
</div>
71+
<div key={i} className="pl-2 min-w-0">
72+
<div className="flex items-start gap-2 py-0.5 min-w-0" style={{ paddingLeft: `${indent * 16}px` }}>
73+
<span className={`shrink-0 size-4 mt-0.5 font-mono text-xs ${colorClass}`}>{label || " "}</span>
74+
<span className="text-xs" dangerouslySetInnerHTML={{ __html: toInlineHtml(taskMatch[3].trim()) }} />
7775
</div>
7876
</div>
7977
);

packages/vscode-ide-companion/src/webview/components/SessionList.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ export default function SessionList({ sessions, activeSessionId, onSelect, onCre
8888
<DrawerTrigger asChild>
8989
<Tooltip>
9090
<TooltipTrigger asChild>
91-
<Button variant="ghost" size="icon" className="shrink-0 cursor-pointer" title="Show Agent Sessions Sidebar">
91+
<Button
92+
variant="ghost"
93+
size="icon"
94+
className="shrink-0 cursor-pointer"
95+
title="Show Agent Sessions Sidebar"
96+
onClick={() => setDrawerOpen(true)}
97+
>
9298
<PanelRight className="h-4 w-4" />
9399
</Button>
94100
</TooltipTrigger>

packages/vscode-ide-companion/src/webview/components/ThinkingLiveBubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function ThinkingLiveBubble({
5151
}, [llmStreamProgress, processes]);
5252

5353
return (
54-
<div className="flex gap-2 mb-3 px-4">
54+
<div className="flex gap-2 mb-3 px-4 w-full max-w-237.5 mx-auto min-w-sm">
5555
<BubbleDot connectToPrev={shouldConnect} className="mt-1" />
5656
<div className="flex items-center gap-2 text-sm text-muted-foreground">
5757
<Spinner className="h-3 w-3" />

packages/vscode-ide-companion/src/webview/components/bubbles/SystemBubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function SystemBubble({ content, meta, shouldConnect = false }: S
1717

1818
return (
1919
<Collapsible open={open} onOpenChange={setOpen} className="relative w-full flex gap-2 mb-3">
20-
<BubbleDot connectToPrev={shouldConnect} className="mt-4" />
20+
<BubbleDot connectToPrev={shouldConnect} className="mt-3.5" />
2121
<div className="absolute left-0.75 h-full w-px bg-muted-foreground top-6"></div>
2222
<div className="flex-1 min-w-0">
2323
<CollapsibleTrigger asChild>

packages/vscode-ide-companion/src/webview/components/bubbles/ThinkingBubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function ThinkingBubble({ content, shouldConnect = false }: Think
1515

1616
return (
1717
<Collapsible open={open} onOpenChange={setOpen} className="relative flex w-full gap-2 rounded-md mb-3">
18-
<BubbleDot connectToPrev={shouldConnect} className="mt-4" />
18+
<BubbleDot connectToPrev={shouldConnect} className="mt-3.5" />
1919
<div className="absolute left-0.75 h-full w-px bg-muted-foreground top-6"></div>
2020
<div className="flex-1 min-w-0 data-[state=open]:bg-muted">
2121
<CollapsibleTrigger asChild>

packages/vscode-ide-companion/src/webview/components/bubbles/ToolBubble.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import PlanRenderer from "@/webview/components/PlanRenderer";
66
import DiffPreview from "@/webview/components/DiffPreview";
77
import { ChevronDown } from "lucide-react";
88
import { Button } from "@/webview/components/ui/button";
9+
import { Tooltip, TooltipContent, TooltipTrigger } from "@/webview/components/ui/tooltip";
910

1011
interface ToolBubbleProps {
1112
content: string;
@@ -59,7 +60,7 @@ export default function ToolBubble({ content, meta, shouldConnect = false }: Too
5960

6061
return (
6162
<Collapsible open={open} onOpenChange={setOpen} className="relative flex w-full gap-2 mb-3">
62-
<BubbleDot variant={isOk ? "success" : "error"} connectToPrev={shouldConnect} className="mt-4" />
63+
<BubbleDot variant={isOk ? "success" : "error"} connectToPrev={shouldConnect} className="mt-3.5" />
6364
<div className="absolute left-0.75 h-full w-px bg-muted-foreground top-6"></div>
6465
<div className="flex-1 min-w-0">
6566
<CollapsibleTrigger asChild>
@@ -69,7 +70,16 @@ export default function ToolBubble({ content, meta, shouldConnect = false }: Too
6970
>
7071
<span className="font-medium">{toolName}</span>
7172
{paramsMd && (
72-
<div className="text-xs break-all w-auto text-left flex-1 text-muted-foreground truncate">{paramsMd}</div>
73+
<Tooltip>
74+
<TooltipTrigger asChild>
75+
<div className="flex-1 min-w-0 text-left text-xs text-muted-foreground cursor-pointer">
76+
<span className="text-wrap line-clamp-1">{paramsMd}</span>
77+
</div>
78+
</TooltipTrigger>
79+
<TooltipContent>
80+
<p>{paramsMd}</p>
81+
</TooltipContent>
82+
</Tooltip>
7383
)}
7484
<ChevronDown className={`ml-auto group-data-[state=open]:rotate-180`} />
7585
</Button>

packages/vscode-ide-companion/src/webview/components/markdown/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132

133133
.markdown-content pre {
134134
margin: 1em 0;
135-
padding: 1em;
135+
/*padding: 1em;*/
136136
overflow-x: auto;
137137
background-color: var(--muted, rgba(0, 0, 0, 0.05));
138138
border: 1px solid var(--border);

0 commit comments

Comments
 (0)