The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 05:45 UTC
fix(web): long server lists in thread details now page 4 at a time (#28684)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Bilal Bakr committed
Nov 3, 2026 at 21:03 UTC
e53672d8fc72f0cf2d50420080314b33ff2c6f33
4 files changed
+113
-8
apps/web/src/components/chat/ThreadDetailsCard.browser.test.tsx
+19
@@ -44,6 +44,7 @@ function Card({
44
fixture,
45
rows = 1,
46
automationRows = 0,
47
+ serverOverflowRows = 0,
48
}: {
49
threadRef: ScopedThreadRef;
50
inline: boolean;
@@ -52,6 +53,8 @@ function Card({
53
rows?: number;
54
/** Rows of 100px in an automations list shown at full density. */
55
automationRows?: number;
56
+ /** Rows of 100px that expanded server lists add, which density ignores. */
57
+ serverOverflowRows?: number;
58
}) {
59
return (
60
// The web root renders in StrictMode, which re-runs ref callbacks on every mount.
@@ -83,6 +86,12 @@ function Card({
86
{density === "full" && automationRows > 0 ? (
87
<section data-thread-automations-panel style={{ height: automationRows * 100 }} />
88
) : null}
89
+ {density === "full" && serverOverflowRows > 0 ? (
90
+ <div
91
+ data-thread-details-server-overflow
92
+ style={{ height: serverOverflowRows * 100 }}
93
+ />
94
+ ) : null}
95
</>
96
)}
97
</ThreadDetailsCard>
@@ -177,3 +186,13 @@ it("keeps full density when many automations make the content tall", async () =>
186
.element(page.getByRole("region", { name: "Thread details" }))
187
.toHaveAttribute("data-density", "full");
188
});
189
+
190
+it("stays full while expanded server rows overflow", async () => {
191
+ using fixture = setup();
192
+ await using _screen = await render(
193
+ <Card threadRef={threadB} inline fixture={fixture} rows={2} serverOverflowRows={4} />,
194
+ );
195
+ await expect
196
+ .element(page.getByRole("region", { name: "Thread details" }))
197
+ .toHaveAttribute("data-density", "full");
198
+});
apps/web/src/components/chat/ThreadDetailsCard.tsx
+3
-3
@@ -78,10 +78,10 @@ export function ThreadDetailsCard({
78
const measure = () => {
79
const frame = element.closest<HTMLElement>("[data-thread-details-card]");
80
const next = element.offsetHeight + (frame ? frame.offsetHeight - frame.clientHeight : 0);
81
- // PR lists, lineage, side chats and automations scroll as they grow. Counting them toward
82
- // density would hide the section and workspace controls when the user asks to see more rows.
81
+ // PR lists, servers, lineage, side chats and automations scroll as they grow. Counting them
82
+ // toward density would hide the section and workspace controls when the user asks to see more.
83
const lists = element.querySelectorAll<HTMLElement>(
84
- "[data-thread-relationships-panel], [data-thread-side-chats-panel], [data-thread-details-pr-list], [data-thread-automations-panel]",
84
+ "[data-thread-relationships-panel], [data-thread-side-chats-panel], [data-thread-details-pr-list], [data-thread-automations-panel], [data-thread-details-server-overflow]",
85
);
86
const fittingHeight =
87
next - Array.from(lists).reduce((sum, list) => sum + list.offsetHeight, 0);
apps/web/src/components/chat/ThreadServersPanel.browser.test.tsx
new
+51
@@ -0,0 +1,51 @@
1
+import { EnvironmentId, ThreadId, type DiscoveredLocalServer } from "@t3tools/contracts";
2
+import { expect, it, vi } from "vite-plus/test";
3
+import { page } from "vite-plus/test/browser";
4
+
5
+vi.mock(import("../../portDiscoveryState"), async (importOriginal) => ({
6
+ ...(await importOriginal()),
7
+ useThreadDiscoveredPorts: () =>
8
+ Array.from(
9
+ { length: 10 },
10
+ (_, index) =>
11
+ ({
12
+ pid: index,
13
+ port: 3000 + index,
14
+ url: `http://localhost:${3000 + index}`,
15
+ terminal: null,
16
+ processName: "node",
17
+ }) as DiscoveredLocalServer,
18
+ ),
19
+}));
20
+
21
+import { render } from "../../../test/render";
22
+import { ThreadServersPanel } from "./ThreadServersPanel";
23
+
24
+const panel = (threadId: string) => (
25
+ <ThreadServersPanel
26
+ environmentId={EnvironmentId.make("env")}
27
+ threadId={ThreadId.make(threadId)}
28
+ />
29
+);
30
+
31
+it("pages servers four at a time, collapses back, and resets on thread switch", async () => {
32
+ await using screen = await render(panel("a"));
33
+ const count = (selector: string) => screen.container.querySelectorAll(selector).length;
34
+ const expectRows = (rows: number) => vi.waitFor(() => expect(count("li")).toBe(rows));
35
+
36
+ await expectRows(4);
37
+ await page.getByRole("button", { name: "Show 4 more" }).click();
38
+ await expectRows(8);
39
+ expect(count("[data-thread-details-server-overflow]")).toBe(4);
40
+ await page.getByRole("button", { name: "Show 2 more" }).click();
41
+ await expectRows(10);
42
+ await page.getByRole("button", { name: "Show less" }).click();
43
+ await expectRows(4);
44
+
45
+ await page.getByRole("button", { name: "Show 4 more" }).click();
46
+ await expectRows(8);
47
+ await screen.rerender(panel("b"));
48
+ await expectRows(4);
49
+ await screen.rerender(panel("a"));
50
+ await expectRows(4);
51
+});
apps/web/src/components/chat/ThreadServersPanel.tsx
+40
-5
@@ -10,6 +10,7 @@ import {
10
isAtomCommandInterrupted,
11
squashAtomCommandFailure,
12
} from "@t3tools/client-runtime/state/runtime";
13
+import { ChevronDown, ChevronUp } from "lucide";
14
import { GlobeIcon, LoaderCircleIcon, SquareIcon } from "lucide-react";
15
import { type MouseEvent, useState } from "react";
16
@@ -21,6 +22,7 @@ import { useEnvironment } from "../../state/environments";
22
import { previewEnvironment } from "../../state/preview";
23
import { useEnvironmentScope } from "../../state/session";
24
import { useAtomCommand } from "../../state/use-atom-command";
25
+import { MorphIcon } from "../MorphIcon";
26
import { openDiscoveredPort } from "../preview/openDiscoveredPort";
27
import { stackedThreadToast, toastManager } from "../ui/toast";
28
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -28,13 +30,21 @@ import { ThreadDetailsControl } from "./ThreadDetailsControl";
30
import { ThreadDetailsSection } from "./ThreadDetailsSection";
31
import { THREAD_DETAILS_PANEL_ICON_CLASS } from "./threadDetailsPanelStyles";
32
33
+const SERVER_PAGE_COUNT = 4;
34
+
35
const serverKey = (server: DiscoveredLocalServer) => `${server.pid}:${server.port}`;
36
33
-/** Local servers the thread's terminals and agent started. Hidden while none run. */
34
-export function ThreadServersPanel(props: {
37
+interface ThreadServersPanelProps {
38
readonly environmentId: EnvironmentId;
39
readonly threadId: ThreadId;
37
-}) {
40
+}
41
+
42
+/** Local servers the thread's terminals and agent started. Hidden while none run. */
43
+export function ThreadServersPanel(props: ThreadServersPanelProps) {
44
+ return <ThreadServersList key={`${props.environmentId}:${props.threadId}`} {...props} />;
45
+}
46
+
47
+function ThreadServersList(props: ThreadServersPanelProps) {
48
const servers = useThreadDiscoveredPorts(props);
49
const canOpen = useEnvironmentScope(props.environmentId, AuthPreviewOperateScope);
50
const canStop = useAtomValue(
@@ -48,10 +58,12 @@ export function ThreadServersPanel(props: {
58
label: "thread server stop",
59
});
60
const [stoppingKey, setStoppingKey] = useState<string | null>(null);
61
+ const [visibleCount, setVisibleCount] = useState(SERVER_PAGE_COUNT);
62
63
if (servers.length === 0) return null;
64
const externalClickLabel = isMacPlatform(navigator.platform) ? "⌘-click" : "Ctrl-click";
65
const threadRef = scopeThreadRef(props.environmentId, props.threadId);
66
+ const hiddenCount = Math.max(0, servers.length - visibleCount);
67
68
const reportFailure = (title: string, error: unknown) => {
69
toastManager.add(
@@ -96,11 +108,15 @@ export function ThreadServersPanel(props: {
108
return (
109
<ThreadDetailsSection headingId="thread-details-servers-heading" title="Servers">
110
<ul className="m-0 list-none p-0">
99
- {servers.map((server) => {
111
+ {servers.slice(0, visibleCount).map((server, index) => {
112
const key = serverKey(server);
113
const stoppable = canStop && supportsStop && server.pid !== null;
114
return (
103
- <li key={key} className="group relative flex items-center rounded-lg">
115
+ <li
116
+ key={key}
117
+ data-thread-details-server-overflow={index >= SERVER_PAGE_COUNT || undefined}
118
+ className="group relative flex items-center rounded-lg"
119
+ >
120
<Tooltip>
121
<TooltipTrigger
122
delay={200}
@@ -163,6 +179,25 @@ export function ThreadServersPanel(props: {
179
);
180
})}
181
</ul>
182
+ {servers.length > SERVER_PAGE_COUNT ? (
183
+ <ThreadDetailsControl
184
+ variant="ghost"
185
+ size="sm"
186
+ onClick={() =>
187
+ setVisibleCount(hiddenCount > 0 ? visibleCount + SERVER_PAGE_COUNT : SERVER_PAGE_COUNT)
188
+ }
189
+ part="row"
190
+ tone="muted"
191
+ className="w-full active:scale-100"
192
+ >
193
+ <MorphIcon
194
+ aria-hidden
195
+ className="size-4 shrink-0"
196
+ icon={hiddenCount > 0 ? ChevronDown : ChevronUp}
197
+ />
198
+ {hiddenCount > 0 ? `Show ${Math.min(hiddenCount, SERVER_PAGE_COUNT)} more` : "Show less"}
199
+ </ThreadDetailsControl>
200
+ ) : null}
201
</ThreadDetailsSection>
202
);
203
}