GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): constrain and announce sidebar thread ports · pingdotgg/t3code@3ed6087

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/sidebar
    • SidebarThreadRow.browser.test.tsx
    • SidebarThreadRow.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/sidebar/SidebarThreadRow.browser.test.tsx‎

Copy file name to clipboard
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { expect, it, vi } from "vite-plus/test";
2+
3+
import { render } from "../../../test/render";
4+
import { __setClientSettingsForTests, getClientSettings } from "../../hooks/useSettings";
5+
import { makeThreadFixture } from "../../test-fixtures";
6+
import { SidebarSearchResultRow } from "./SidebarThreadRow";
7+
8+
vi.mock("../../portDiscoveryState", () => ({
9+
useThreadDiscoveredPorts: () => [{ port: 3000 }, { port: 4000 }, { port: 5000 }],
10+
}));
11+
12+
it("announces running ports when navigating a search result with an explicit name", async () => {
13+
const initial = getClientSettings();
14+
using _settings = { [Symbol.dispose]: () => __setClientSettingsForTests(initial) };
15+
__setClientSettingsForTests({ ...initial, sidebarShowPorts: true });
16+
await using screen = await render(
17+
<ul role="listbox" aria-label="Threads">
18+
<SidebarSearchResultRow
19+
thread={makeThreadFixture({ title: "Dev server" })}
20+
project={null}
21+
projectDisplayName={null}
22+
environmentLabel={null}
23+
environmentMachine="desktop"
24+
providerEntryByInstanceId={new Map()}
25+
isSettled={false}
26+
isHighlighted={false}
27+
isRouteActive={false}
28+
resultId="port-result"
29+
searchMatch={null}
30+
searchQuery="Dev"
31+
onHighlight={vi.fn()}
32+
onSelect={vi.fn()}
33+
onFileDropThreads={vi.fn()}
34+
/>
35+
</ul>,
36+
);
37+
38+
await expect
39+
.element(screen.getByRole("option", { name: "Dev server" }))
40+
.toHaveAccessibleDescription("Running ports: 3000, 4000, 5000");
41+
});
Collapse file

‎apps/web/src/components/sidebar/SidebarThreadRow.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/sidebar/SidebarThreadRow.tsx
+36-12Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import {
5454
} from "lucide-react";
5555
import {
5656
memo,
57+
useId,
5758
useRef,
5859
useState,
5960
type KeyboardEvent as ReactKeyboardEvent,
@@ -132,22 +133,41 @@ export type SidebarProviderEntry = Pick<
132133
| "acpRegistryIconUrl"
133134
| "models"
134135
>;
135-
function ThreadPorts({ thread }: { thread: SidebarThreadSummary }) {
136+
function ThreadPorts({
137+
thread,
138+
descriptionId,
139+
}: {
140+
thread: SidebarThreadSummary;
141+
descriptionId: string;
142+
}) {
136143
const enabled = useClientSettings((settings) => settings.sidebarShowPorts);
137144
const servers = useThreadDiscoveredPorts({
138145
environmentId: enabled ? thread.environmentId : null,
139146
threadId: thread.id,
140147
});
141148
const ports = [...new Set(servers.map((server) => server.port))].sort((a, b) => a - b);
142149
if (ports.length === 0) return null;
150+
const description = `Running ports: ${ports.join(", ")}`;
143151
return (
144-
<span
145-
className="inline-flex shrink-0 items-center gap-1 text-xs text-muted-foreground tabular-nums"
146-
aria-label={`Running ports: ${ports.join(", ")}`}
147-
>
148-
<NetworkIcon aria-hidden="true" className="size-3" />
149-
{ports.join(", ")}
150-
</span>
152+
<>
153+
<span id={descriptionId} className="sr-only">
154+
{description}
155+
</span>
156+
<Tooltip>
157+
<TooltipTrigger
158+
render={
159+
<span
160+
aria-hidden="true"
161+
className="inline-flex max-w-[40%] shrink-0 items-center gap-1 text-xs text-muted-foreground tabular-nums"
162+
/>
163+
}
164+
>
165+
<NetworkIcon className="size-3 shrink-0" />
166+
<span className="min-w-0 truncate">{ports.join(", ")}</span>
167+
</TooltipTrigger>
168+
<TooltipPopup>{description}</TooltipPopup>
169+
</Tooltip>
170+
</>
151171
);
152172
}
153173

@@ -675,6 +695,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
675695
variant,
676696
variantAction,
677697
} = props;
698+
const portsDescriptionId = useId();
678699
const threadRef = scopeThreadRef(thread.environmentId, thread.id);
679700
const threadKey = scopedThreadKey(threadRef);
680701
const canOperateThread = useEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope);
@@ -1235,6 +1256,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
12351256
data-sidebar-row={threadKey}
12361257
data-sidebar-parent={props.navigationParent}
12371258
aria-label={accessibility.label}
1259+
aria-describedby={portsDescriptionId}
12381260
aria-current={accessibility.current}
12391261
data-testid={inFolder ? "sidebar-row-folder" : "sidebar-row-slim"}
12401262
aria-busy={isRegeneratingTitle || undefined}
@@ -1271,7 +1293,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
12711293
)}
12721294
{draftIndicator}
12731295
{title}
1274-
<ThreadPorts thread={thread} />
1296+
<ThreadPorts thread={thread} descriptionId={portsDescriptionId} />
12751297
{multiline ? titleLineIcons : null}
12761298
{pinIndicator}
12771299
{multiline ? null : terminalStatusIcon}
@@ -1432,6 +1454,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
14321454
data-sidebar-row={threadKey}
14331455
data-sidebar-parent={props.navigationParent}
14341456
aria-label={accessibility.label}
1457+
aria-describedby={portsDescriptionId}
14351458
aria-current={accessibility.current}
14361459
data-testid="sidebar-row-card"
14371460
aria-busy={isRegeneratingTitle || undefined}
@@ -1597,7 +1620,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
15971620
</div>
15981621
<div className="mt-1 flex min-w-0 items-center gap-1.5">
15991622
{title}
1600-
<ThreadPorts thread={thread} />
1623+
<ThreadPorts thread={thread} descriptionId={portsDescriptionId} />
16011624
{isRegeneratingTitle ? (
16021625
<span role="status" className="sr-only">
16031626
Regenerating title
@@ -1655,6 +1678,7 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
16551678
projectDisplayName: props.projectDisplayName,
16561679
isActive: props.isRouteActive,
16571680
});
1681+
const portsDescriptionId = useId();
16581682
const threadRef = scopeThreadRef(thread.environmentId, thread.id);
16591683
const { leaseLiveStatus, rowRef } = useSidebarRowSubscriptionLease(
16601684
props.isHighlighted || props.isRouteActive,
@@ -1721,7 +1745,7 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
17211745
tabIndex={-1}
17221746
aria-selected={props.isHighlighted}
17231747
aria-current={accessibility.current}
1724-
aria-describedby={`${props.resultId}-pr`}
1748+
aria-describedby={`${props.resultId}-pr ${portsDescriptionId}`}
17251749
aria-label={accessibility.label}
17261750
onMouseMove={props.onHighlight}
17271751
onClick={props.onSelect}
@@ -1762,7 +1786,7 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
17621786
>
17631787
{thread.title}
17641788
</span>
1765-
<ThreadPorts thread={thread} />
1789+
<ThreadPorts thread={thread} descriptionId={portsDescriptionId} />
17661790
<span id={`${props.resultId}-pr`} className="contents">
17671791
<ThreadSearchPullRequestNumber
17681792
thread={thread}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.