Skip to content

Commit d9c8cd4

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-33531
2 parents db31116 + ee59ab2 commit d9c8cd4

26 files changed

Lines changed: 976 additions & 128 deletions

‎apps/desktop/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@t3tools/desktop",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"private": true,
55
"type": "module",
66
"main": "dist-electron/boot.cjs",

‎apps/mobile/src/features/layout/inspector-host.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ const PANE_HEADER_OPTIONS = { ...GLASS_HEADER_OPTIONS, headerShown: false };
2323

2424
function PaneHeader(props: { readonly store: InspectorBarStore }) {
2525
const options = useSyncExternalStore(props.store.subscribe, props.store.getSnapshot);
26-
return <V5StackHeader options={{ ...PANE_HEADER_OPTIONS, ...options }} canGoBack={false} />;
26+
// Its own search identity, so opening the inspector doesn't morph the sidebar's search into it.
27+
return (
28+
<V5StackHeader
29+
options={{ ...PANE_HEADER_OPTIONS, ...options }}
30+
canGoBack={false}
31+
searchIdentifier="inspector-search"
32+
/>
33+
);
2734
}
2835

2936
function PaneScreenContent(props: {

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

Lines changed: 98 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ import Animated, {
114114
} from "react-native-reanimated";
115115
import { useSafeAreaInsets } from "react-native-safe-area-context";
116116
import { useBarOverlap } from "../../components/ui/useBarInset";
117-
import { useWorkspaceContentWidth } from "../layout/workspace-content-width";
117+
import {
118+
useWorkspaceContentWidth,
119+
WorkspaceSettledContentWidthContext,
120+
} from "../layout/workspace-content-width";
118121
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
119122
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
120123
import {
@@ -317,6 +320,17 @@ export interface ThreadDetailScreenProps {
317320

318321
// iOS questions overlay the controls; Android questions stack with child approvals.
319322
const ComposerPanels = Platform.OS === "android" ? Animated.ScrollView : Animated.View;
323+
324+
/** Hands the feed the screen width measured for a native column; elsewhere keeps the inherited one. */
325+
function ColumnWidth(props: { readonly width: number | null; readonly children: React.ReactNode }) {
326+
return props.width === null ? (
327+
props.children
328+
) : (
329+
<WorkspaceSettledContentWidthContext value={props.width}>
330+
{props.children}
331+
</WorkspaceSettledContentWidthContext>
332+
);
333+
}
320334
const USAGE_LIMITS_PANEL_GAP = 12;
321335
const USAGE_LIMITS_PANEL_MIN_HEIGHT = 44;
322336

@@ -1022,8 +1036,13 @@ function ThreadDetailBody(
10221036
// Android lays the screen out below its opaque header and reports a zero
10231037
// header height, so the window height overstates the room by the header.
10241038
const [screenHeight, setScreenHeight] = useState<number | null>(null);
1039+
const [screenWidth, setScreenWidth] = useState<number | null>(null);
10251040
const handleScreenLayout = (event: LayoutChangeEvent) => {
10261041
setScreenHeight(event.nativeEvent.layout.height);
1042+
const width = Math.round(event.nativeEvent.layout.width);
1043+
setScreenWidth((current) =>
1044+
current !== null && Math.abs(current - width) <= 1 ? current : width,
1045+
);
10271046
};
10281047
const screenAreaHeight = screenHeight ?? windowHeight;
10291048
const draftViewportHeight = screenAreaHeight - navigationHeaderHeight - liveKeyboardHeight;
@@ -1211,6 +1230,13 @@ function ThreadDetailBody(
12111230
}
12121231
: { width: "auto", right: controlInsets.right },
12131232
);
1233+
// A native column resizes the screen before JS hears of it. The feed and the composer take the
1234+
// measured width in one render, so they change size together rather than the composer first.
1235+
const columnWidth = usesNativeWorkspaceColumns && isSplitLayout ? screenWidth : null;
1236+
const columnComposerWidthStyle =
1237+
columnWidth === null
1238+
? null
1239+
: { width: Math.max(0, columnWidth - controlInsets.left - controlInsets.right) };
12141240
const selectedInstanceId = props.selectedThread.modelSelection.instanceId;
12151241
useAtomMount(threadStreamHaptics(props.selectedThreadDetailRef));
12161242
const selectedProviderSkills = (() => {
@@ -1436,54 +1462,58 @@ function ThreadDetailBody(
14361462
)}
14371463
>
14381464
<WorkspaceMutationIdProvider threadRef={props.selectedThreadDetailRef}>
1439-
<ThreadFeed
1440-
toolCallVisibility={toolCallVisibility}
1441-
environmentId={props.environmentId}
1442-
threadId={props.selectedThread.id}
1443-
detailRef={props.selectedThreadDetailRef}
1444-
workspaceRoot={props.threadCwd}
1445-
feed={props.selectedThreadFeed}
1446-
pendingHandoff={props.pendingHandoff}
1447-
worktreeSetup={props.worktreeSetup}
1448-
setupWorkingStartedAt={props.setupWorkingStartedAt}
1449-
queuedMessages={props.queuedMessages}
1450-
dispatchingMessageId={props.dispatchingMessageId}
1451-
// A native subagent has no composer to edit a pending message in;
1452-
// Cancel on the edit banner would discard it.
1453-
onEditPendingMessage={
1454-
isProviderSubagent || pendingMessageEditBlocked ? null : handleEditPendingMessage
1455-
}
1456-
contentPresentation={props.contentPresentation}
1457-
threadTitle={props.selectedThread.title}
1458-
latestRun={props.activityRun}
1459-
activeWorkStartedAt={props.activeWorkStartedAt}
1460-
runlessWorkActive={props.runlessWorkActive ?? false}
1461-
listRef={listRef}
1462-
freeze={freeze}
1463-
anchorMessageId={anchorMessageId}
1464-
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1465-
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1466-
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1467-
keyboardOffset={composerKeyboardOffset}
1468-
sendingWithKeyboard={sendingWithKeyboard}
1469-
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1470-
contentTopInset={0}
1471-
contentBottomInset={
1472-
questionInFlow
1473-
? 0
1474-
: estimatedOverlayHeight +
1475-
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1476-
}
1477-
contentMaxWidth={contentMaxWidth}
1478-
historyControls={props.historyControls}
1479-
contentSideInsets={nativeMetrics?.safeArea}
1480-
layoutVariant={layoutVariant}
1481-
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1482-
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1483-
onIsAtEndChange={setIsAtEnd}
1484-
skills={selectedProviderSkills}
1485-
onUseArtifactTemplate={handleUseArtifactTemplate}
1486-
/>
1465+
<ColumnWidth width={columnWidth}>
1466+
<ThreadFeed
1467+
toolCallVisibility={toolCallVisibility}
1468+
environmentId={props.environmentId}
1469+
threadId={props.selectedThread.id}
1470+
detailRef={props.selectedThreadDetailRef}
1471+
workspaceRoot={props.threadCwd}
1472+
feed={props.selectedThreadFeed}
1473+
pendingHandoff={props.pendingHandoff}
1474+
worktreeSetup={props.worktreeSetup}
1475+
setupWorkingStartedAt={props.setupWorkingStartedAt}
1476+
queuedMessages={props.queuedMessages}
1477+
dispatchingMessageId={props.dispatchingMessageId}
1478+
// A native subagent has no composer to edit a pending message in;
1479+
// Cancel on the edit banner would discard it.
1480+
onEditPendingMessage={
1481+
isProviderSubagent || pendingMessageEditBlocked
1482+
? null
1483+
: handleEditPendingMessage
1484+
}
1485+
contentPresentation={props.contentPresentation}
1486+
threadTitle={props.selectedThread.title}
1487+
latestRun={props.activityRun}
1488+
activeWorkStartedAt={props.activeWorkStartedAt}
1489+
runlessWorkActive={props.runlessWorkActive ?? false}
1490+
listRef={listRef}
1491+
freeze={freeze}
1492+
anchorMessageId={anchorMessageId}
1493+
jumpToMessageId={jumpMessageLoaded ? jumpMessageId : null}
1494+
onJumpedToMessage={() => finishThreadMessageJump(selectedThreadKey)}
1495+
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1496+
keyboardOffset={composerKeyboardOffset}
1497+
sendingWithKeyboard={sendingWithKeyboard}
1498+
fitShortFeedToViewport={questionInFlow && !isKeyboardVisible}
1499+
contentTopInset={0}
1500+
contentBottomInset={
1501+
questionInFlow
1502+
? 0
1503+
: estimatedOverlayHeight +
1504+
(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0)
1505+
}
1506+
contentMaxWidth={contentMaxWidth}
1507+
historyControls={props.historyControls}
1508+
contentSideInsets={nativeMetrics?.safeArea}
1509+
layoutVariant={layoutVariant}
1510+
usesAutomaticContentInsets={props.usesAutomaticContentInsets}
1511+
onHeaderMaterialVisibilityChange={props.onHeaderMaterialVisibilityChange}
1512+
onIsAtEndChange={setIsAtEnd}
1513+
skills={selectedProviderSkills}
1514+
onUseArtifactTemplate={handleUseArtifactTemplate}
1515+
/>
1516+
</ColumnWidth>
14871517
</WorkspaceMutationIdProvider>
14881518
</RenderErrorBoundary>
14891519
</View>
@@ -1533,18 +1563,25 @@ function ThreadDetailBody(
15331563
pointerEvents="box-none"
15341564
style={
15351565
questionInFlow
1536-
? isSplitLayout
1537-
? composerWidthStyle
1538-
: undefined
1539-
: [
1540-
{
1541-
position: "absolute",
1542-
bottom: controlInsets.bottom,
1543-
left: controlInsets.left,
1544-
right: controlInsets.right,
1545-
},
1546-
composerWidthStyle,
1547-
]
1566+
? (columnComposerWidthStyle ?? (isSplitLayout ? composerWidthStyle : undefined))
1567+
: columnComposerWidthStyle
1568+
? [
1569+
{
1570+
position: "absolute",
1571+
bottom: controlInsets.bottom,
1572+
left: controlInsets.left,
1573+
},
1574+
columnComposerWidthStyle,
1575+
]
1576+
: [
1577+
{
1578+
position: "absolute",
1579+
bottom: controlInsets.bottom,
1580+
left: controlInsets.left,
1581+
right: controlInsets.right,
1582+
},
1583+
composerWidthStyle,
1584+
]
15481585
}
15491586
>
15501587
{/* No paddingTop here: the overlay's measured height becomes the

‎apps/mobile/src/native/V5StackHeader.ios.tsx‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ export function V5StackHeader(props: {
156156
readonly column?: "primary" | "detail";
157157
/** The workspace's compose action, shown as its own group in this column's bar. */
158158
readonly onCompose?: () => void;
159+
/** UIKit morphs search items that share an identifier between bars as columns change. */
160+
readonly searchIdentifier?: string;
159161
}) {
160162
const { options } = props;
161163
const theme = useMobileNavigationTheme();
@@ -182,7 +184,14 @@ export function V5StackHeader(props: {
182184
const bottom = toolbar.flatMap<HeaderItem>((item, index) => {
183185
if (item.type === "mailSearchToolbar") return [];
184186
if (item.type === "searchBarPlacement")
185-
return [{ type: "item", id: `toolbar-search:${index}`, searchBarPlacement: true }];
187+
return [
188+
{
189+
type: "item",
190+
id: `toolbar-search:${index}`,
191+
searchBarPlacement: true,
192+
...(props.searchIdentifier ? { identifier: props.searchIdentifier } : {}),
193+
},
194+
];
186195
return convertItems([item], `toolbar:${index}`);
187196
});
188197
if (mailSearch) {
@@ -199,7 +208,12 @@ export function V5StackHeader(props: {
199208
if (bottomSearch) {
200209
if (spacesSearch && bottom.length)
201210
bottom.push({ type: "spacer", id: "before-search", sizing: "fixed", width: 8 });
202-
bottom.push({ type: "item", id: "home-search", searchBarPlacement: true });
211+
bottom.push({
212+
type: "item",
213+
id: "home-search",
214+
searchBarPlacement: true,
215+
...(props.searchIdentifier ? { identifier: props.searchIdentifier } : {}),
216+
});
203217
if (spacesSearch && mailSearch.onComposePress)
204218
bottom.push({ type: "spacer", id: "after-search", sizing: "fixed", width: 8 });
205219
}

‎apps/server/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "t3",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

‎apps/server/src/auth/McpOAuth.test.ts‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AuthMcpClientAccess,
55
AuthStandardClientScopes,
66
type AuthCreatePairingCredentialInput,
7+
type EnvironmentCloudLinkStateResult,
78
EnvironmentHttpApi,
89
MCP_PEER_LINK_SOFTWARE_ID,
910
mcpClientScopes,
@@ -21,6 +22,7 @@ import * as HttpApi from "effect/http-api/HttpApi";
2122
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
2223
import * as Schema from "effect/Schema";
2324

25+
import * as CloudLink from "../cloud/CloudLink.ts";
2426
import * as ServerConfig from "../config.ts";
2527
import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
2628
import * as ServerSettings from "../serverSettings.ts";
@@ -44,7 +46,17 @@ const layerEnvironmentAuth = EnvironmentAuth.layer.pipe(
4446
Layer.provideMerge(ServerEnvironment.layerIdentity),
4547
Layer.provide(layerConfig),
4648
);
47-
const makeLayerRoutes = (capture: (auth: EnvironmentAuth.EnvironmentAuth["Service"]) => void) =>
49+
const notLinked: EnvironmentCloudLinkStateResult = {
50+
linked: false,
51+
cloudUserId: null,
52+
relayUrl: null,
53+
relayIssuer: null,
54+
publishAgentActivity: false,
55+
};
56+
const makeLayerRoutes = (
57+
capture: (auth: EnvironmentAuth.EnvironmentAuth["Service"]) => void,
58+
linkState: EnvironmentCloudLinkStateResult,
59+
) =>
4860
Layer.mergeAll(
4961
Layer.effectDiscard(
5062
EnvironmentAuth.EnvironmentAuth.pipe(Effect.tap((auth) => Effect.sync(() => capture(auth)))),
@@ -55,6 +67,9 @@ const makeLayerRoutes = (capture: (auth: EnvironmentAuth.EnvironmentAuth["Servic
5567
McpOAuthHttp.layer.pipe(
5668
Layer.provide(McpOAuth.layer),
5769
Layer.provide(ServerSettings.layerTest({ linkedEnvironmentsEnabled: true })),
70+
Layer.provide(
71+
Layer.mock(CloudLink.CloudLink)({ linkState: () => Effect.succeed(linkState) }),
72+
),
5873
),
5974
),
6075
Layer.provide(AuthHttp.layerAuthenticatedAuth),
@@ -92,14 +107,15 @@ type Handler = (request: Request) => Effect.Effect<Response>;
92107

93108
const withRoutes = <A, E>(
94109
use: (handler: Handler, auth: EnvironmentAuth.EnvironmentAuth["Service"]) => Effect.Effect<A, E>,
110+
linkState = notLinked,
95111
) =>
96112
Effect.gen(function* () {
97113
const random = yield* SecureRandom.SecureRandom;
98114
const context = Context.make(SecureRandom.SecureRandom, random);
99115
let routerAuth: EnvironmentAuth.EnvironmentAuth["Service"] | undefined;
100116
const layerRoutes = makeLayerRoutes((auth) => {
101117
routerAuth = auth;
102-
});
118+
}, linkState);
103119
return yield* Effect.acquireUseRelease(
104120
Effect.sync(() => HttpRouter.toWebHandler(layerRoutes, { disableLogger: true })),
105121
(web) =>
@@ -594,6 +610,28 @@ it.live("an app approval code approves only an app sign-in, at its own level", (
594610
),
595611
);
596612

613+
it.live("offers T3 Connect approval only on the linked tunnel's own host", () =>
614+
Effect.gen(function* () {
615+
const connectSignIn = (tunnelHostname: string) =>
616+
withRoutes(
617+
(handler) =>
618+
Effect.gen(function* () {
619+
const params = authorizeParams(yield* registeredClientId(handler));
620+
const details = yield* handler(postJson("/oauth/mcp/approval", params)).pipe(
621+
Effect.flatMap(json<{ connectSignIn?: unknown }>),
622+
);
623+
return details.connectSignIn;
624+
}),
625+
{ ...notLinked, linked: true, cloudUserId: "user_1", tunnelHostname },
626+
);
627+
expect(yield* connectSignIn("box.example.ts.net")).toEqual({
628+
environmentId: expect.any(String),
629+
hostedAppUrl: "https://app.t3.codes",
630+
});
631+
expect(yield* connectSignIn("other.t3coderelay.com")).toBeUndefined();
632+
}),
633+
);
634+
597635
it.live("one-click approves only access the browser session holds the scopes for", () =>
598636
withRoutes((handler, auth) =>
599637
Effect.gen(function* () {

0 commit comments

Comments
 (0)