Skip to content

Commit 5524822

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-26515
2 parents ce3c3e5 + ccc7b2d commit 5524822

11 files changed

Lines changed: 163 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,16 @@ jobs:
140140
- name: Start installing browser secret helper build libraries
141141
if: needs.changes.outputs.build != 'false'
142142
run: |
143-
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
143+
# Fetch only the indexes these main and universe packages need. The full set is ~42 MB,
144+
# which a slow mirror can stretch past the wait below.
145+
sudo sed -i -e 's|http://|https://|g' -e 's/^Components: .*/Components: main universe/' \
146+
/etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
144147
(
145148
set +e
146-
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config xvfb
149+
sudo apt-get update -o Acquire::Languages=none \
150+
-o Acquire::IndexTargets::deb::DEP-11::DefaultEnabled=false \
151+
-o Acquire::IndexTargets::deb::CNF::DefaultEnabled=false &&
152+
sudo apt-get install -y libsecret-1-dev pkg-config xvfb
147153
echo "$?" > "$RUNNER_TEMP/apt-status"
148154
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
149155
@@ -287,10 +293,16 @@ jobs:
287293
# the background while Vite+ installs; the step before the tests waits for it.
288294
- name: Start installing browser secret helper build libraries
289295
run: |
290-
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
296+
# Fetch only the indexes these main and universe packages need. The full set is ~42 MB,
297+
# which a slow mirror can stretch past the wait below.
298+
sudo sed -i -e 's|http://|https://|g' -e 's/^Components: .*/Components: main universe/' \
299+
/etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
291300
(
292301
set +e
293-
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
302+
sudo apt-get update -o Acquire::Languages=none \
303+
-o Acquire::IndexTargets::deb::DEP-11::DefaultEnabled=false \
304+
-o Acquire::IndexTargets::deb::CNF::DefaultEnabled=false &&
305+
sudo apt-get install -y libsecret-1-dev pkg-config
294306
echo "$?" > "$RUNNER_TEMP/apt-status"
295307
) > "$RUNNER_TEMP/apt.log" 2>&1 < /dev/null &
296308

‎apps/web/src/components/chat/McpAppFrame.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
1313
import {
1414
clampMcpAppHeight,
15+
MCP_APP_COLOR_SCHEME_PARAM,
1516
MCP_APP_DEFAULT_HEIGHT,
1617
MCP_APP_MAX_HEIGHT,
1718
mcpAppAllowAttribute,
@@ -125,7 +126,12 @@ export function McpAppFrame(props: {
125126
// The frame keeps its first URL: a re-minted one would reload the app.
126127
const [src, setSrc] = useState<string | null>(null);
127128
const asset = useLongLivedAssetUrl(src === null ? props.environmentId : null, resource);
128-
if (src === null && asset._tag === "Success") setSrc(asset.url);
129+
if (src === null && asset._tag === "Success") {
130+
// The app paints before `ui/initialize`, so it reads the initial scheme from its URL.
131+
const url = new URL(asset.url);
132+
url.searchParams.set(MCP_APP_COLOR_SCHEME_PARAM, theme.appearance);
133+
setSrc(url.toString());
134+
}
129135

130136
const detail = useTurnItemDetail({
131137
environmentId: props.environmentId,

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ function PullRequestCodeTab({
15031503
</CollapsibleTrigger>
15041504
</h2>
15051505
<CollapsiblePanel>
1506-
<div className="max-h-64 space-y-3 overflow-auto px-4 pb-3">
1506+
<div className="max-h-64 space-y-1 overflow-auto px-1 pb-1">
15071507
{[...orphanFiles].map(([path, threads]) => (
15081508
<div key={path}>
15091509
<Tooltip>

‎apps/web/src/components/pullRequest/PullRequestReviewAnnotation.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export function ReviewThreadCard({
229229

230230
return (
231231
<div
232-
className={CARD_CLASS}
232+
className={cn(CARD_CLASS, !expanded && "py-1")}
233233
contentEditable={false}
234234
onPointerDown={(event) => event.stopPropagation()}
235235
>
@@ -250,7 +250,7 @@ export function ReviewThreadCard({
250250
{thread.isOutdated ? <span>outdated</span> : null}
251251
{onFix ? (
252252
<Button
253-
size="xs"
253+
size="compact"
254254
variant="ghost"
255255
className="ml-auto"
256256
disabled={pending || fixPending}
@@ -262,7 +262,7 @@ export function ReviewThreadCard({
262262
) : null}
263263
{onAddToChat && comments.some((comment) => visibleBody(comment.body) !== null) ? (
264264
<Button
265-
size="xs"
265+
size="compact"
266266
variant="ghost"
267267
className={onFix ? undefined : "ml-auto"}
268268
onClick={() => onAddToChat({ ...thread, comments })}
@@ -273,7 +273,7 @@ export function ReviewThreadCard({
273273
) : null}
274274
{canResolve ? (
275275
<Button
276-
size="xs"
276+
size="compact"
277277
variant="ghost"
278278
className={onFix || onAddToChat ? undefined : "ml-auto"}
279279
disabled={pending}

‎docs/operations/scenarios.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@ cd scripts && pnpm exec e2e run scenarios/replay-turn-streams.e2e.ts --headed
7070

7171
e2e starts the dev stack through [`start-app.ts`](../../scripts/scenarios/start-app.ts) on a free
7272
port, runs the tests, and stops it. Results land in `scripts/.e2e`: `report.json`, `summary.md`,
73-
and per test a `trace.md`, its screenshots, and a video. The first run downloads e2e's browser.
73+
and per test a `trace.md`, its screenshots, and a video. `vp run scenarios --target web` runs one
74+
target; flags go straight after the script name, without `--`.
75+
76+
The first run downloads e2e's browser (about 120 MB). To fetch it ahead of time, such as in a
77+
machine image, run this from the repository root after `vp i`:
78+
79+
```sh
80+
node scripts/node_modules/playwright-core/cli.js install --only-shell chromium ffmpeg
81+
```
82+
83+
e2e opens the web app at `127.0.0.1`, and the start script tells the web dev server to bind that
84+
address. It does not use `localhost`, which some machines resolve to `::1` first.
85+
7486
`e2e run --help` lists the rest: `--grep`, `--watch`, `--last-failed`, `--changed-since`.
7587

7688
Run one at a time per checkout: a run recreates the checkout's scenario T3 home and its `.e2e`

‎packages/client-runtime/src/pullRequestQuery.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ describe("reading qualifiers out of a typed query", () => {
3333
review: "changes-requested",
3434
checks: "failing",
3535
});
36+
expect(parsePullRequestQuery("-draft:true").filters).toEqual({ draft: "hide" });
3637
});
3738

3839
it("leaves an unknown value and a stray colon as text, and reads an unknown key as a label", () => {
@@ -53,6 +54,20 @@ describe("reading qualifiers out of a typed query", () => {
5354
]);
5455
});
5556

57+
// regression: #30131 a query pasted from github.com lists nothing
58+
it("ignores GitHub's own search qualifiers instead of reading them as labels", () => {
59+
expect(
60+
parsePullRequestQuery(
61+
"is:pr state:open archived:false repo:org/repo org:org user:alice sort:updated-desc -repo:org/fork -state:closed fix",
62+
),
63+
).toEqual({ text: "fix", filters: {} });
64+
});
65+
66+
it("sets no author when the query names more than one", () => {
67+
expect(parsePullRequestQuery("author:alice author:bob").filters).toEqual({});
68+
expect(parsePullRequestQuery("author:me author:@me").filters).toEqual({ author: "me" });
69+
});
70+
5671
it("cuts a typed query back to what the contract carries", () => {
5772
const many = Array.from({ length: 14 }, (_, index) => `l${index}`).join(",");
5873
const long = "x".repeat(240);

‎packages/client-runtime/src/pullRequestQuery.ts‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ function splitQualifierList(raw: string): string[] {
2929
.filter((part) => part.length > 0);
3030
}
3131

32+
/** `me` and `@me` both name the viewer; logins are case-insensitive. */
33+
function authorKey(login: string): string {
34+
return login.toLowerCase().replace(/^@me$/, "me");
35+
}
36+
3237
function boundedNames(names: ReadonlyArray<string>): string[] {
3338
return names
3439
.slice(0, MAX_QUALIFIER_VALUES)
@@ -43,7 +48,8 @@ export function parsePullRequestQuery(raw: string): {
4348
const text: string[] = [];
4449
const labels: string[][] = [];
4550
const excludedLabels: string[] = [];
46-
let author: string | undefined;
51+
// `null` once two different logins are named: GitHub ORs them, the contract carries one.
52+
let author: string | null | undefined;
4753
let draft: PullRequestListFilters["draft"];
4854
let review: PullRequestListFilters["review"];
4955
let checks: PullRequestListFilters["checks"];
@@ -59,13 +65,16 @@ export function parsePullRequestQuery(raw: string): {
5965
else labels.push(names);
6066
continue;
6167
}
62-
case "author":
68+
case "author": {
6369
if (negated) break;
64-
author = value.slice(0, MAX_QUALIFIER_LENGTH).trim();
70+
const login = value.slice(0, MAX_QUALIFIER_LENGTH).trim();
71+
if (author === undefined) author = login;
72+
else if (author === null || authorKey(author) !== authorKey(login)) author = null;
6573
continue;
74+
}
6675
case "draft":
67-
if (negated || (value.toLowerCase() !== "true" && value.toLowerCase() !== "false")) break;
68-
draft = value.toLowerCase() === "true" ? "only" : "hide";
76+
if (value.toLowerCase() !== "true" && value.toLowerCase() !== "false") break;
77+
draft = (value.toLowerCase() === "true") !== negated ? "only" : "hide";
6978
continue;
7079
case "review": {
7180
const decision = negated ? undefined : REVIEW_VALUES[value.toLowerCase()];
@@ -80,6 +89,15 @@ export function parsePullRequestQuery(raw: string): {
8089
checks = state;
8190
continue;
8291
}
92+
// GitHub's own search qualifiers, not labels: the list sets scope and order itself.
93+
case "is":
94+
case "archived":
95+
case "state":
96+
case "repo":
97+
case "org":
98+
case "user":
99+
case "sort":
100+
continue;
83101
case "":
84102
break;
85103
default:
@@ -104,7 +122,7 @@ export function parsePullRequestQuery(raw: string): {
104122
...(excludedLabels.length === 0
105123
? {}
106124
: { excludedLabels: excludedLabels.slice(0, MAX_QUALIFIER_VALUES) }),
107-
...(author === undefined ? {} : { author }),
125+
...(typeof author === "string" ? { author } : {}),
108126
...(draft === undefined ? {} : { draft }),
109127
...(review === undefined ? {} : { review }),
110128
...(checks === undefined ? {} : { checks }),

‎packages/shared/src/mcpApp.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
injectMcpAppCsp,
66
injectMcpAppThemeBootstrap,
77
injectMcpAppCookieBootstrap,
8+
MCP_APP_COLOR_SCHEME_PARAM,
89
mcpAppContentSecurityPolicy,
910
mcpAppToolCallableByApp,
1011
mcpAppToolResourceUri,
@@ -101,6 +102,28 @@ describe("injectMcpAppThemeBootstrap", () => {
101102
send(initialized);
102103
expect(style.colorScheme).toBe("dark");
103104
});
105+
106+
it("applies only a valid scheme from the frame URL before any message arrives", () => {
107+
const html = injectMcpAppThemeBootstrap("<p>app</p>");
108+
const script = html.slice(html.indexOf("<script>") + 8, html.indexOf("</script>"));
109+
const initialScheme = (search: string) => {
110+
const head: Array<{ name?: string; content?: string }> = [];
111+
NodeVM.runInNewContext(script, {
112+
URLSearchParams,
113+
location: { search },
114+
window: { parent: {}, addEventListener: () => {} },
115+
document: {
116+
createElement: () => ({}),
117+
head: { append: (element: (typeof head)[number]) => head.push(element) },
118+
},
119+
});
120+
return head.find((element) => element.name === "color-scheme")?.content ?? "normal";
121+
};
122+
expect(initialScheme(`?a=1&${MCP_APP_COLOR_SCHEME_PARAM}=dark`)).toBe("dark");
123+
expect(initialScheme(`?${MCP_APP_COLOR_SCHEME_PARAM}=light`)).toBe("light");
124+
expect(initialScheme(`?${MCP_APP_COLOR_SCHEME_PARAM}=normal`)).toBe("normal");
125+
expect(initialScheme("")).toBe("normal");
126+
});
104127
});
105128

106129
describe("readMcpAppCsp", () => {

‎packages/shared/src/mcpApp.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
55
export const MCP_APP_EXTENSION_ID = "io.modelcontextprotocol/ui";
66
export const MCP_APP_RESOURCE_SCHEME = "ui://";
77
export const MCP_APP_OUTPUT_KEY = "t3McpApp";
8+
/** Frame URL query parameter carrying the host's color scheme before `ui/initialize`. */
9+
export const MCP_APP_COLOR_SCHEME_PARAM = "t3-color-scheme";
810

911
const MCP_APP_MIN_HEIGHT = 80;
1012
export const MCP_APP_DEFAULT_HEIGHT = 320;
@@ -201,6 +203,16 @@ export function injectMcpAppCsp(html: string, csp: McpAppCsp | undefined): strin
201203
export function injectMcpAppThemeBootstrap(html: string): string {
202204
const script = `<script>
203205
(() => {
206+
try {
207+
const initial = new URLSearchParams(location.search).get(${JSON.stringify(MCP_APP_COLOR_SCHEME_PARAM)});
208+
if (initial === "light" || initial === "dark") {
209+
// A meta tag, unlike an inline style, survives the app's own <html style> attribute.
210+
const meta = document.createElement("meta");
211+
meta.name = "color-scheme";
212+
meta.content = initial;
213+
document.head.append(meta);
214+
}
215+
} catch {}
204216
window.addEventListener("message", (event) => {
205217
if (event.source !== window.parent) return;
206218
const message = event.data;

‎scripts/e2e.config.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ export const T3_HOME = resolved.home;
4646
export const MOBILE_T3_HOME = `${T3_HOME}-mobile`;
4747
export const MOBILE = resolved.mobile;
4848
const startApp = resolved.startApp;
49+
/**
50+
* The one address e2e opens the web app at and the app is told to bind. Never `localhost`: the
51+
* runner and the app can resolve that name to different addresses.
52+
*/
53+
const LOOPBACK = "127.0.0.1";
4954

5055
/**
5156
* Leases a device from the Simlock pool, whose gateway speaks agent-device's lease protocol.
@@ -131,12 +136,12 @@ export default {
131136
name: "web",
132137
engine: web({ viewport: { width: 1280, height: 800 } }),
133138
app: {
134-
url: "http://127.0.0.1:0",
139+
url: `http://${LOOPBACK}:0`,
135140
// Vite answers before the server does; this path is proxied to the server.
136-
readyUrl: "http://127.0.0.1:{port}/.well-known/t3/environment",
141+
readyUrl: `http://${LOOPBACK}:{port}/.well-known/t3/environment`,
137142
command: {
138143
executable: resolved.node,
139-
args: [startApp, "web", T3_HOME, "{port}"],
144+
args: [startApp, "web", T3_HOME, LOOPBACK, "{port}"],
140145
cwd: APP_DIR,
141146
startupTimeout: 300_000,
142147
log: ".e2e/app.log",

0 commit comments

Comments
 (0)