Skip to content

Commit 004b286

Browse files
committed
Merge origin/main into t3/improve-xlsx-preview
2 parents da10573 + bc3eb6d commit 004b286

62 files changed

Lines changed: 1361 additions & 206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Platform, TextInput, View } from "react-native";
1010
import { useSafeAreaInsets } from "react-native-safe-area-context";
1111

1212
import { ControlPill } from "../../components/ui/ControlPill";
13+
import { useContentTopInset } from "../../components/ui/useBarInset";
1314
import { useAppForeground } from "../../lib/appState";
1415

1516
import { useThreadServerBrowserTabs } from "../../state/preview";
@@ -56,6 +57,7 @@ function BrowserPreviewScreen({
5657
readonly onClose: () => void;
5758
}) {
5859
const insets = useSafeAreaInsets();
60+
const contentTopInset = useContentTopInset();
5961
const { themeVariables } = useAppearancePreferences();
6062
const prepared = usePreparedConnection(environmentId);
6163
const httpBaseUrl = Option.isSome(prepared) ? prepared.value.httpBaseUrl : null;
@@ -90,7 +92,10 @@ function BrowserPreviewScreen({
9092
const live = (focused && foreground) || pictureInPicture.active;
9193

9294
return (
93-
<View className="flex-1 bg-sheet" style={{ paddingBottom: insets.bottom }}>
95+
<View
96+
className="flex-1 bg-sheet"
97+
style={{ paddingTop: contentTopInset, paddingBottom: insets.bottom }}
98+
>
9499
<SheetHeader
95100
title={tab ? browserTabTitle(tab) : "Browser"}
96101
onClose={onClose}

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import {
1010
withChipIcon,
1111
} from "../../native/useEnrichedLinkVariants";
1212
import {
13-
enrichedSkillDisplayName,
1413
enrichedSkillInstructionsPath,
1514
enrichedSkillReference,
1615
} from "../../lib/enrichedLinkPresentation";
16+
import { formatProviderSkillDisplayName } from "@t3tools/shared/inlineSkills";
1717
import { ThreadContextDivider } from "./thread-context-divider";
1818
import {
1919
ThreadHandoffDivider,
@@ -2992,7 +2992,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29922992
const skill = enrichedSkillReference(href, props.skills);
29932993
if (skill) {
29942994
return {
2995-
title: enrichedSkillDisplayName(skill),
2995+
title: formatProviderSkillDisplayName(skill),
29962996
actions: [
29972997
{
29982998
id: "open-skill",

‎apps/mobile/src/lib/enrichedLinkPresentation.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,6 @@ export function enrichedSkillLinkRegex(skills?: ReadonlyArray<SelectableMarkdown
105105
);
106106
}
107107

108-
export function enrichedSkillDisplayName(skill: SelectableMarkdownSkill) {
109-
return (
110-
skill.displayName?.trim() ||
111-
skill.name
112-
.split(/[\s:_-]+/)
113-
.filter(Boolean)
114-
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
115-
.join(" ")
116-
);
117-
}
118-
119108
export function enrichedSkillReference(
120109
url: string,
121110
skills?: ReadonlyArray<SelectableMarkdownSkill>,

‎apps/mobile/src/lib/threadActivity.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,48 @@ describe("buildThreadFeed", () => {
393393
expect(buildThreadFeed([projected(reply, 0)])[0]?.type).toBe("message");
394394
});
395395

396+
it.each([false, true])(
397+
"shows an async answer that started a later run where that run begins (cache: %s)",
398+
(cached) => {
399+
const requestId = RuntimeRequestId.make("late-question");
400+
const inRun = (item: OrchestrationV2TurnItem, run: string, position: number) =>
401+
projected({ ...item, runId: RunId.make(run) }, position);
402+
const message = (id: string, role: "user" | "assistant"): OrchestrationV2TurnItem => ({
403+
...(role === "user" ? userMessage() : assistantMessage()),
404+
id: TurnItemId.make(id),
405+
messageId: MessageId.make(id),
406+
});
407+
const answerMessageId = `async-answer:${requestId}`;
408+
const settledPrefix = [
409+
inRun(
410+
{
411+
...base("late-question", "2026-06-20T00:00:01.000Z", 0),
412+
type: "user_input_request",
413+
requestId,
414+
questions: [],
415+
questionAnswer: { requestId, answers: { color: "Blue" }, attachmentsByQuestionId: {} },
416+
},
417+
"run-8",
418+
0,
419+
),
420+
inRun(message("queued", "user"), "run-9", 1),
421+
inRun(message("reply-9", "assistant"), "run-9", 2),
422+
];
423+
const rows = [
424+
...settledPrefix,
425+
inRun(message(answerMessageId, "user"), "run-10", 3),
426+
inRun(message("reply-10", "assistant"), "run-10", 4),
427+
];
428+
const cache = cached ? createThreadFeedCache() : undefined;
429+
if (cache) buildThreadFeed(settledPrefix, { cache });
430+
expect(
431+
buildThreadFeed(rows, { cache }).flatMap((entry) =>
432+
entry.type === "message" ? [entry.id] : [],
433+
),
434+
).toEqual(["queued", "reply-9", answerMessageId, "reply-10"]);
435+
},
436+
);
437+
396438
it.each([false, true])(
397439
"keeps answered questions outside settled work (attachments only: %s)",
398440
(attachmentsOnly) => {

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ interface ThreadFeedBuild {
21142114
readonly attempts: ReadonlyArray<OrchestrationV2RunAttempt> | undefined;
21152115
readonly nodes: ReadonlyArray<OrchestrationV2ExecutionNode> | undefined;
21162116
readonly checkpointSummaries: ReadonlyArray<ThreadCheckpointSummary> | undefined;
2117-
readonly foldedAnswerMessageIds: ReadonlySet<string>;
2117+
readonly foldedAnswerRunIdByMessageId: ReadonlyMap<string, RunId | null>;
21182118
readonly delegatedChildrenByRun: ReadonlyMap<RunId, ReadonlySet<string>>;
21192119
readonly feed: ReadonlyArray<ThreadFeedEntry>;
21202120
/** Grouping is empty before `row`: the rows before it produced `feed.slice(0, feedLength)`. */
@@ -2164,6 +2164,14 @@ function checkpointSummariesEqual(
21642164
});
21652165
}
21662166

2167+
function mapsEqual<K, V>(left: ReadonlyMap<K, V>, right: ReadonlyMap<K, V>): boolean {
2168+
if (left.size !== right.size) return false;
2169+
for (const [key, value] of left) {
2170+
if (!right.has(key) || right.get(key) !== value) return false;
2171+
}
2172+
return true;
2173+
}
2174+
21672175
function setMapsEqual<K, V>(
21682176
left: ReadonlyMap<K, ReadonlySet<V>>,
21692177
right: ReadonlyMap<K, ReadonlySet<V>>,
@@ -2217,11 +2225,12 @@ export function buildThreadFeed(
22172225
};
22182226
// Thread-wide facts that change rows anywhere in the feed. A cached prefix
22192227
// is reused only while these match the build that produced it.
2220-
const foldedAnswerMessageIds = new Set<string>();
2228+
// An answer that started a later run stays a normal message at that run's position.
2229+
const foldedAnswerRunIdByMessageId = new Map<string, RunId | null>();
22212230
const delegatedChildrenByRun = new Map<RunId, Set<string>>();
22222231
for (const { item } of visibleTurnItems) {
22232232
if (item.type === "user_input_request" && item.questionAnswer) {
2224-
foldedAnswerMessageIds.add(`async-answer:${item.questionAnswer.requestId}`);
2233+
foldedAnswerRunIdByMessageId.set(`async-answer:${item.questionAnswer.requestId}`, item.runId);
22252234
} else if (item.type === "subagent" && item.origin === "app_owned" && item.runId !== null) {
22262235
const children = delegatedChildrenByRun.get(item.runId) ?? new Set<string>();
22272236
children.add(item.subagentId);
@@ -2238,7 +2247,7 @@ export function buildThreadFeed(
22382247
previous.attempts === options?.attempts &&
22392248
previous.nodes === options?.nodes &&
22402249
checkpointSummariesEqual(previous.checkpointSummaries, options?.checkpointSummaries) &&
2241-
setsEqual(previous.foldedAnswerMessageIds, foldedAnswerMessageIds) &&
2250+
mapsEqual(previous.foldedAnswerRunIdByMessageId, foldedAnswerRunIdByMessageId) &&
22422251
setMapsEqual(previous.delegatedChildrenByRun, delegatedChildrenByRun)
22432252
) {
22442253
const firstChanged = firstChangedIndex(previous.rows, visibleTurnItems);
@@ -2276,7 +2285,11 @@ export function buildThreadFeed(
22762285
item.status === "pending"
22772286
)
22782287
continue;
2279-
if (item.type === "user_message" && foldedAnswerMessageIds.has(item.messageId)) continue;
2288+
if (
2289+
item.type === "user_message" &&
2290+
foldedAnswerRunIdByMessageId.get(item.messageId) === item.runId
2291+
)
2292+
continue;
22802293
if (
22812294
item.type === "run_interrupt_request" ||
22822295
(item.type === "run_interrupt_result" &&
@@ -2377,7 +2390,7 @@ export function buildThreadFeed(
23772390
entryRows.push(index);
23782391
}
23792392
const retainedMessageIds = new Set([
2380-
...foldedAnswerMessageIds,
2393+
...foldedAnswerRunIdByMessageId.keys(),
23812394
...entries.flatMap((entry) => (entry.type === "message" ? [entry.id] : [])),
23822395
]);
23832396
const appendLocalMessage = (message: LocalThreadMessage): RawThreadFeedEntry => {
@@ -2446,7 +2459,7 @@ export function buildThreadFeed(
24462459
attempts: options?.attempts,
24472460
nodes: options?.nodes,
24482461
checkpointSummaries: options?.checkpointSummaries,
2449-
foldedAnswerMessageIds,
2462+
foldedAnswerRunIdByMessageId,
24502463
delegatedChildrenByRun,
24512464
feed,
24522465
restarts,

‎apps/mobile/src/native/useEnrichedLinkVariants.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import {
1919
enrichedContextLinkPresentation,
2020
enrichedLinkVariantPattern,
2121
enrichedModelReference,
22-
enrichedSkillDisplayName,
2322
enrichedSkillReference,
2423
enrichedThreadLinkPresentation,
2524
} from "../lib/enrichedLinkPresentation";
25+
import { formatProviderSkillDisplayName } from "@t3tools/shared/inlineSkills";
2626

2727
function chipCustomization(
2828
chip: ReturnType<typeof enrichedContextLinkPresentation>,
@@ -70,7 +70,7 @@ function presentation(
7070
const skill = enrichedSkillReference(url, props.skills);
7171
if (skill)
7272
return {
73-
label: enrichedSkillDisplayName(skill),
73+
label: formatProviderSkillDisplayName(skill),
7474
icon: CONTEXT_CHIP_ICON_SOURCES.skill,
7575
chip: { accent: contextChipPresentation("skill").accent, tintsIcon: true },
7676
};

‎apps/server/src/cli/app.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as ConfigProvider from "effect/ConfigProvider";
1717
import * as Effect from "effect/Effect";
1818
import * as Layer from "effect/Layer";
1919
import * as Schema from "effect/Schema";
20+
import * as TestConsole from "effect/testing/TestConsole";
2021
import { Command } from "effect/cli";
2122
import { describe, expect } from "vite-plus/test";
2223

@@ -180,6 +181,15 @@ describe("t3 server command safety", () => {
180181
),
181182
);
182183

184+
it.effect("does not offer auto-bootstrap in serve help, since serve never bootstraps", () =>
185+
Effect.gen(function* () {
186+
yield* runCli(["serve", "--help"]);
187+
const help = (yield* TestConsole.logLines).join("\n");
188+
expect(help).toContain("--no-browser");
189+
expect(help).not.toContain("--auto-bootstrap-project-from-cwd");
190+
}).pipe(Effect.provide(Layer.fresh(TestConsole.layer))),
191+
);
192+
183193
it.effect("refuses manual startup over a live server before creating directories", () =>
184194
withTempDirectory("t3-cli-running-", (root) =>
185195
Effect.gen(function* () {

‎apps/server/src/cli/server.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,21 @@ export const startCommand = Command.make("start", { ...sharedServerCommandFlags
8787
Command.withHandler((flags) => runServerCommand(flags, { rejectRunningServer: true })),
8888
);
8989

90-
export const serveCommand = Command.make("serve", { ...sharedServerCommandFlags }).pipe(
90+
// Serve never bootstraps a project, so it does not offer the flag that asks for one.
91+
const { autoBootstrapProjectFromCwd: _, ...serveCommandFlags } = sharedServerCommandFlags;
92+
93+
export const serveCommand = Command.make("serve", serveCommandFlags).pipe(
9194
Command.withShortDescription("Run T3 Code in this terminal, with no browser."),
9295
Command.withDescription(
9396
"Run T3 Code in this terminal without opening a browser, and print pairing details. The background service runs this. To set up access from your other devices, run `t3 up`.",
9497
),
9598
Command.withHandler((flags) =>
96-
runServerCommand(flags, {
97-
startupPresentation: "headless",
98-
forceAutoBootstrapProjectFromCwd: false,
99-
}),
99+
runServerCommand(
100+
{ ...flags, autoBootstrapProjectFromCwd: Option.none() },
101+
{
102+
startupPresentation: "headless",
103+
forceAutoBootstrapProjectFromCwd: false,
104+
},
105+
),
100106
),
101107
);

‎apps/server/src/git/GitManager.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5002,6 +5002,9 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
50025002
expect(NodeFS.readFileSync(NodePath.join(repoDir, "untracked.txt"), "utf8")).toBe(
50035003
"keep me\n",
50045004
);
5005+
expect(
5006+
(yield* runGit(repoDir, ["config", "branch.feature/pr-safe.t3-pull-request"])).stdout,
5007+
).toBe("https://github.com/pingdotgg/codething-mvp/pull/91\n");
50055008
}),
50065009
);
50075010

‎apps/server/src/git/GitManager.ts‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export class GitManager extends Context.Service<
140140
input: { readonly cwd: string; readonly branch: string },
141141
options?: { readonly refresh?: boolean; readonly freshGitState?: boolean },
142142
) => Effect.Effect<GitBranchPullRequest | null, GitManagerServiceError>;
143+
/** Whether T3 checked this pull request out onto the branch, which ties it to later threads. */
144+
readonly checkedOutPullRequest: (input: {
145+
readonly cwd: string;
146+
readonly branch: string;
147+
readonly url: string;
148+
}) => Effect.Effect<boolean>;
143149
readonly invalidateLocalStatus: (cwd: string) => Effect.Effect<void, never>;
144150
readonly invalidateRemoteStatus: (cwd: string) => Effect.Effect<void, never>;
145151
readonly invalidateStatus: (cwd: string) => Effect.Effect<void, never>;
@@ -2755,6 +2761,9 @@ export const make = Effect.gen(function* () {
27552761
repositoryKey: pullRequestRepositoryKey(latest.url),
27562762
};
27572763
});
2764+
2765+
const checkedOutPullRequestKey = (branch: string) => `branch.${branch}.t3-pull-request`;
2766+
27582767
const branchPullRequest: GitManager["Service"]["branchPullRequest"] = Effect.fn(
27592768
"branchPullRequest",
27602769
)(function* ({ cwd, branch }, options) {
@@ -2799,6 +2808,16 @@ export const make = Effect.gen(function* () {
27992808
}
28002809
return confirmed;
28012810
});
2811+
2812+
const checkedOutPullRequest: GitManager["Service"]["checkedOutPullRequest"] = Effect.fn(
2813+
"checkedOutPullRequest",
2814+
)(function* ({ cwd, branch, url }) {
2815+
const checkedOutUrl = yield* gitCore
2816+
.readConfigValue(cwd, checkedOutPullRequestKey(branch))
2817+
.pipe(Effect.orElseSucceed(() => null));
2818+
return checkedOutUrl === url;
2819+
});
2820+
28022821
const invalidateLocalStatus: GitManager["Service"]["invalidateLocalStatus"] = Effect.fn(
28032822
"invalidateLocalStatus",
28042823
)(function* (cwd) {
@@ -3133,7 +3152,25 @@ export const make = Effect.gen(function* () {
31333152
worktreePath: worktree.worktree.path,
31343153
isOnPullRequestHead: true,
31353154
};
3136-
}).pipe(Effect.ensuring(invalidateStatus(input.cwd)));
3155+
}).pipe(
3156+
Effect.tap((result) =>
3157+
gitCore
3158+
.writeConfigValue({
3159+
cwd: input.cwd,
3160+
key: checkedOutPullRequestKey(result.branch),
3161+
value: result.pullRequest.url,
3162+
})
3163+
.pipe(
3164+
Effect.catch((cause) =>
3165+
Effect.logWarning("GitManager.preparePullRequestThread could not mark the branch", {
3166+
branch: result.branch,
3167+
cause,
3168+
}),
3169+
),
3170+
),
3171+
),
3172+
Effect.ensuring(invalidateStatus(input.cwd)),
3173+
);
31373174
}, asUserAction);
31383175

31393176
const runFeatureBranchStep = Effect.fn("runFeatureBranchStep")(function* (
@@ -3392,6 +3429,7 @@ export const make = Effect.gen(function* () {
33923429
remoteStatus,
33933430
status,
33943431
branchPullRequest,
3432+
checkedOutPullRequest,
33953433
invalidateLocalStatus,
33963434
invalidateRemoteStatus,
33973435
invalidateStatus,

0 commit comments

Comments
 (0)