Skip to content

Commit 30a593b

Browse files
committed
chore: merge main
2 parents 321cdca + 812c0a7 commit 30a593b

80 files changed

Lines changed: 2533 additions & 622 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/review/reviewModel.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { parsePatchFiles } from "@pierre/diffs/utils/parsePatchFiles";
22
import type { ChangeTypes, FileDiffMetadata } from "@pierre/diffs/types";
3-
import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thread-checkpoints";
3+
import {
4+
checkpointFileTotals,
5+
type ThreadCheckpointSummary,
6+
} from "@t3tools/client-runtime/state/thread-checkpoints";
47
import type { ReviewDiffPreviewSource } from "@t3tools/contracts";
58
import { quoteGitPatchPath } from "@t3tools/shared/gitPatchPath";
69
import * as Arr from "effect/Array";
@@ -107,7 +110,7 @@ function checkpointTitle(checkpoint: ThreadCheckpointSummary): string {
107110
}
108111

109112
function checkpointSubtitle(checkpoint: ThreadCheckpointSummary): string {
110-
const fileCount = checkpoint.files.length;
113+
const fileCount = checkpointFileTotals(checkpoint).count;
111114
if (checkpoint.status !== "ready") {
112115
return `Diff ${checkpoint.status}`;
113116
}

‎apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import {
1212
isLearned,
1313
} from "@t3tools/client-runtime/connection";
1414
import { type EnvironmentId, sessionGrantsScope } from "@t3tools/contracts";
15-
import { AUTH_SCOPE_OPTIONS } from "@t3tools/shared/authScopeOptions";
15+
import {
16+
AUTH_SCOPE_OPTIONS,
17+
sessionPermissionsUnavailableMessage,
18+
} from "@t3tools/shared/authScopeOptions";
1619
import { AsyncResult } from "effect/reactivity";
1720
import * as Option from "effect/Option";
1821
import { useState } from "react";
@@ -163,8 +166,14 @@ export function EnvironmentRoutesSection({
163166
</>
164167
) : (
165168
<Text className="text-sm text-foreground-muted">
166-
Permissions not checked. Connect to this environment to view this session’s
167-
permissions.
169+
{sessionPermissionsUnavailableMessage({
170+
connected: activeRouteId !== null,
171+
failed: sessionResult._tag === "Failure",
172+
rejected:
173+
sessionResult._tag !== "Failure" &&
174+
!sessionResult.waiting &&
175+
session?.authenticated === false,
176+
})}
168177
</Text>
169178
)}
170179
</View>

‎apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
type ServerProvider,
99
} from "@t3tools/contracts";
1010
import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
11+
import { sessionPermissionsUnavailableMessage } from "@t3tools/shared/authScopeOptions";
1112
import * as Cause from "effect/Cause";
1213
import * as Exit from "effect/Exit";
1314
import { AsyncResult } from "effect/reactivity";
@@ -208,11 +209,14 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
208209
</Text>
209210
) : !allowed ? (
210211
<Text className="px-2 text-sm text-foreground-muted">
211-
{AsyncResult.isFailure(sessionResult)
212-
? "Could not verify your permissions. Reconnect to try again."
213-
: session === null
214-
? "Checking permissions…"
215-
: "This connection does not have permission to manage the environment."}
212+
{AsyncResult.isFailure(sessionResult) || session === null || !session.authenticated
213+
? sessionPermissionsUnavailableMessage({
214+
connected,
215+
failed: AsyncResult.isFailure(sessionResult),
216+
rejected:
217+
!AsyncResult.isFailure(sessionResult) && session?.authenticated === false,
218+
})
219+
: "This connection does not have permission to manage the environment."}
216220
</Text>
217221
) : null}
218222
{error ? (

‎apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import {
1818
NativeWorkspaceTabActivityContext,
1919
WorkspaceSlotOptionsContext,
2020
} from "../../native/v5-workspace-context";
21-
import { useCompactWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
21+
import {
22+
useCompactWorkspaceTabs,
23+
useFloatingWorkspaceTabs,
24+
useSystemWorkspaceTabBar,
25+
} from "./useSystemWorkspaceTabBar";
2226
import { useControlTheme } from "../../components/ui/useControlTheme";
2327
import { useDeviceType } from "../../native/native-layout-metrics";
2428
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
@@ -80,7 +84,7 @@ export function WorkspaceNativeTabs(props: {
8084
const deviceType = useDeviceType();
8185
const compactTabs = useCompactWorkspaceTabs();
8286
const { layout, startNewTask } = useAdaptiveWorkspaceLayout();
83-
const compactSidebarTabs = deviceType === "phone" || !layout.usesSplitView;
87+
const floatingTabs = useFloatingWorkspaceTabs();
8488
const { width } = useWindowDimensions();
8589
const { colors } = useControlTheme();
8690
const selectedTab = workspace.state.selectedTab;
@@ -158,17 +162,17 @@ export function WorkspaceNativeTabs(props: {
158162
bottom: 0,
159163
// UIKit can shrink the sidebar to 280pt independently of its preferred width.
160164
width:
161-
deviceType === "pad"
165+
deviceType === "pad" && (floatingTabs || layout.usesSplitView)
162166
? Math.min(280, layout.listPaneWidth ?? width, width)
163167
: (layout.listPaneWidth ?? width),
164168
height: 128,
165169
}}
166170
>
167171
<WorkspaceSidebarTabs
168-
compact={compactSidebarTabs}
169-
reserveComposeSpace={compactSidebarTabs}
172+
compact={floatingTabs}
173+
reserveComposeSpace={floatingTabs}
170174
onNewTask={
171-
compactSidebarTabs && !workspace.settingsOpen && selectedTab === "threads"
175+
floatingTabs && !workspace.settingsOpen && selectedTab === "threads"
172176
? startNewTask
173177
: undefined
174178
}

‎apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
1717
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
1818
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
19-
import { useCompactWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
19+
import { useFloatingWorkspaceTabs, useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
2020
import { WorkspaceTabToolbarButtons } from "./WorkspaceSectionToolbar";
2121

2222
const SEARCH_LABELS = {
@@ -33,7 +33,7 @@ export function WorkspaceToolbar(props: {
3333
const activeNewTask = useActiveNewTask();
3434
const deviceType = useDeviceType();
3535
const sidebarTabs = useSidebarWorkspaceTabs();
36-
const compactTabs = useCompactWorkspaceTabs();
36+
const floatingTabs = useFloatingWorkspaceTabs();
3737
const duoSearch = NATIVE_LIQUID_GLASS_SUPPORTED && isDuoDevice(deviceType);
3838
const bottomSearch = duoSearch && sidebarTabs !== "picker";
3939
// On the Duo, compose belongs to the threads tab, in the detail column's bar when unfolded.
@@ -45,7 +45,7 @@ export function WorkspaceToolbar(props: {
4545
activeNewTask === null;
4646
const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
4747
const focused = useIsFocused();
48-
const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
48+
const { layout, panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
4949
const searchRef = useRef<SearchBarCommands>(null);
5050
// The Settings list takes the selected tab's place, so search follows it.
5151
const selectedTab = workspace.settingsOpen ? "settings" : workspace.state.selectedTab;
@@ -189,9 +189,9 @@ export function WorkspaceToolbar(props: {
189189
{composeButton}
190190
{selectedTab !== "threads" ||
191191
isDuoDevice(deviceType) ||
192-
deviceType === "pad" ||
192+
(deviceType === "pad" && layout.usesSplitView) ||
193193
sidebarTabs === "picker" ||
194-
compactTabs ? null : (
194+
floatingTabs ? null : (
195195
<Toolbar.Button
196196
accessibilityLabel="New chat"
197197
icon="square.and.pencil"

‎apps/mobile/src/features/workspace/useSystemWorkspaceTabBar.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { isDuoDevice } from "../../lib/device-type";
22
import { Platform } from "react-native";
3+
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
34
import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
45
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
56
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
@@ -37,6 +38,18 @@ export function useCompactWorkspaceTabs() {
3738
);
3839
}
3940

41+
/** The workspace tab bar floats with compose beside it. Before iOS 26 UITabBar is opaque and
42+
* full width, so it sits flush and compose stays in the header. */
43+
export function useFloatingWorkspaceTabs() {
44+
const { layout } = useAdaptiveWorkspaceLayout();
45+
const deviceType = useDeviceType();
46+
const compactTabs = useCompactWorkspaceTabs();
47+
return (
48+
NATIVE_LIQUID_GLASS_SUPPORTED &&
49+
(compactTabs || (deviceType === "pad" && !layout.usesSplitView))
50+
);
51+
}
52+
4053
export function useSystemWorkspaceTabBar() {
4154
const deviceType = useDeviceType();
4255
const { layout } = useAdaptiveWorkspaceLayout();

‎apps/server/integration/transferBudgetV2.integration.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const layerManagement = Layer.unwrap(
117117
.pipe(Effect.orDie),
118118
getThreadShell: (id) => projections.getThreadShell(id).pipe(Effect.orDie),
119119
getShellSnapshot: (options) => projections.getShellSnapshot(options).pipe(Effect.orDie),
120+
listActiveShellIndex: () => projections.listActiveShellIndex().pipe(Effect.orDie),
120121
listActiveSubagentThreadIds: () =>
121122
projections.listActiveSubagentThreadIds().pipe(Effect.orDie),
122123
readShellSnapshot: (options) =>

‎apps/server/src/device/DeviceHubProxy.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,32 @@ describe("device hub proxy", () => {
169169
expect(headers[0]?.["content-type"]).toBe("application/json");
170170
});
171171

172+
it("lets a viewer read Android stream capabilities and signal WebRTC with read scope", async () => {
173+
const { handler, requests } = fixture([AuthOrchestrationReadScope]);
174+
const hub = "http://t3.test/api/device-hub/vendor/serve-emu";
175+
const api = await handler(new Request(`${hub}/api?device=session-1`));
176+
expect(api.status).toBe(200);
177+
await api.text();
178+
for (const action of ["offer", "close"]) {
179+
const signal = await handler(
180+
new Request(`${hub}/webrtc/${action}?device=session-1`, {
181+
method: "POST",
182+
headers: { "content-type": "application/json" },
183+
body: '{"sessionId":"viewer"}',
184+
}),
185+
);
186+
expect(signal.status).toBe(200);
187+
await signal.text();
188+
}
189+
expect(requests).toEqual([
190+
"http://hub.test/vendor/serve-emu/api?device=session-1",
191+
"http://hub.test/vendor/serve-emu/webrtc/offer?device=session-1",
192+
"http://hub.test/vendor/serve-emu/webrtc/close?device=session-1",
193+
]);
194+
expect((await handler(new Request(`${hub}/api`, { method: "POST" }))).status).toBe(405);
195+
expect((await handler(new Request(`${hub}/webrtc/offer`))).status).toBe(405);
196+
});
197+
172198
it("sends requests a host routes itself to its upstream with its credentials", async () => {
173199
const { handler, requests, headers } = fixture(
174200
[AuthOrchestrationReadScope],

‎apps/server/src/device/DeviceHubProxy.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ const ALLOWED_PATHS: ReadonlyArray<RegExp> = [
2727
/^\/vendor\/serve-sim\/helper\/[^/]+\/panel\/(1|3)\/stream\.avcc$/,
2828
/^\/vendor\/serve-sim\/helper\/[^/]+\/webrtc\/(offer|close)$/,
2929
/^\/vendor\/serve-sim\/appstate$/,
30+
/^\/vendor\/serve-emu\/api$/,
3031
/^\/vendor\/serve-emu\/api\/(devices|screenshot|stream-mode|stream-settings|accessibility|fold)$/,
3132
/^\/vendor\/serve-emu\/health$/,
3233
];
3334

35+
// Paths that take methods besides GET; one missing from ALLOWED_PATHS takes no GET.
3436
const MUTABLE_PATHS: ReadonlyArray<RegExp> = [
3537
/^\/vendor\/serve-sim\/api\/screenshot$/,
3638
// WebRTC signalling: opening and closing a view of the stream, so read scope.
3739
/^\/vendor\/serve-sim\/helper\/[^/]+\/webrtc\/(offer|close)$/,
40+
/^\/vendor\/serve-emu\/webrtc\/(offer|close)$/,
3841
/^\/vendor\/serve-emu\/api\/(screenshot|stream-mode|stream-settings)$/,
3942
/^\/vendor\/serve-emu\/api\/fold$/,
4043
];
@@ -178,14 +181,15 @@ const handler = Effect.gen(function* () {
178181
}
179182
const hubPath = url.value.pathname.slice(DeviceService.DEVICE_HUB_ROUTE_PREFIX.length) || "/";
180183
const upgrade = isWebSocketUpgrade(request);
181-
const allowed = (upgrade ? ALLOWED_WS_PATHS : ALLOWED_PATHS).some((pattern) =>
182-
pattern.test(hubPath),
183-
);
184+
const matches = (paths: ReadonlyArray<RegExp>) => paths.some((pattern) => pattern.test(hubPath));
185+
const allowed = upgrade
186+
? matches(ALLOWED_WS_PATHS)
187+
: matches(ALLOWED_PATHS) || matches(MUTABLE_PATHS);
184188
if (!allowed) {
185189
return HttpServerResponse.text("Not Found", { status: 404 });
186190
}
187191
const readOnly = request.method === "GET" || request.method === "HEAD";
188-
if (!upgrade && !readOnly && !MUTABLE_PATHS.some((pattern) => pattern.test(hubPath))) {
192+
if (!upgrade && !matches(readOnly ? ALLOWED_PATHS : MUTABLE_PATHS)) {
189193
return HttpServerResponse.text("Method Not Allowed", { status: 405 });
190194
}
191195
const controlsDevice =

0 commit comments

Comments
 (0)