Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/mobile/src/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { DynamicColorIOS, Platform, Pressable, ScrollView, StyleSheet } from "re
import { useResolveClassNames } from "uniwind";

import { AppText as Text } from "./components/AppText";
import { renderCompactBrandTitle } from "./components/CompactBrandTitle";
import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
import { ClerkSettingsSheetDetentProvider } from "./features/cloud/ClerkSettingsSheetDetent";
Expand Down Expand Up @@ -378,8 +377,7 @@ export const RootStack = createNativeStackNavigator({
...GLASS_HEADER_OPTIONS,
contentStyle: { backgroundColor: "transparent" },
headerBackVisible: false,
headerTitle: renderCompactBrandTitle,
title: "T3 Code",
title: "Threads",
},
}),
Thread: createNativeStackScreen({
Expand Down
60 changes: 0 additions & 60 deletions apps/mobile/src/components/CompactBrandTitle.tsx

This file was deleted.

5 changes: 1 addition & 4 deletions apps/mobile/src/features/home/HomeRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useNavigation } from "@react-navigation/native";
import { useMemo, useState } from "react";

import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
import { renderCompactBrandTitle } from "../../components/CompactBrandTitle";
import { useProjects, useThreadShells } from "../../state/entities";
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
import { useWorkspaceState } from "../../state/workspace";
Expand Down Expand Up @@ -87,9 +86,7 @@ export function HomeRouteScreen() {
>
<>
{/* Restore the compact title in case the split branch blanked it. */}
<NativeStackScreenOptions
options={{ title: "T3 Code", headerTitle: renderCompactBrandTitle }}
/>
<NativeStackScreenOptions options={{ title: "Threads", headerTitle: "Threads" }} />
<HomeHeader
environments={environments}
searchQuery={searchQuery}
Expand Down
11 changes: 10 additions & 1 deletion apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,20 @@ export function HomeScreen(props: HomeScreenProps) {
onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
variant="plain"
/>
{emptyState.loading ? (
{emptyState.loading && !shouldShowConnectionStatus ? (
<View className="mt-4 items-center">
<ActivityIndicator color={accentColor} />
</View>
) : null}
{shouldShowConnectionStatus && Platform.OS === "ios" ? (
<View className="mt-4">
<WorkspaceConnectionStatus
state={props.catalogState}
onPress={props.onOpenEnvironments}
variant="sidebar"
/>
</View>
) : null}
</View>
{connectionStatus}
</View>
Expand Down
17 changes: 17 additions & 0 deletions apps/mobile/src/features/home/WorkspaceConnectionStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ describe("workspace connection status", () => {
expect(shouldShowWorkspaceConnectionStatus(state)).toBe(true);
expect(workspaceConnectionStatusLabel(state)).toBe("Could not reach Julius’s Mac mini");
});

it("shows shell catch-up while cached threads remain visible", () => {
const state = workspaceState({ hasPendingShellSnapshot: true });

expect(shouldShowWorkspaceConnectionStatus(state)).toBe(true);
expect(workspaceConnectionStatusLabel(state)).toBe("Syncing threads...");
});

it("distinguishes initial shell loading from cached catch-up", () => {
const state = workspaceState({
hasLoadedShellSnapshot: false,
hasPendingShellSnapshot: true,
});

expect(shouldShowWorkspaceConnectionStatus(state)).toBe(true);
expect(workspaceConnectionStatusLabel(state)).toBe("Loading threads...");
});
});
7 changes: 5 additions & 2 deletions apps/mobile/src/features/home/WorkspaceConnectionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export function WorkspaceConnectionStatus(props: {
readonly variant?: "floating" | "sidebar";
}) {
const iconColor = useThemeColor("--color-icon-muted");
const isReconnecting = props.state.connectingEnvironments.length > 0;
const isSynchronizing =
props.state.networkStatus !== "offline" &&
props.state.connectionError === null &&
(props.state.connectingEnvironments.length > 0 || props.state.hasPendingShellSnapshot);
const variant = props.variant ?? "floating";

return (
Expand All @@ -37,7 +40,7 @@ export function WorkspaceConnectionStatus(props: {
: undefined
}
>
{isReconnecting ? (
{isSynchronizing ? (
<ActivityIndicator color={iconColor} size="small" />
) : (
<SymbolView name="wifi.slash" size={15} tintColor={iconColor} type="monochrome" />
Expand Down
4 changes: 4 additions & 0 deletions apps/mobile/src/features/home/workspace-connection-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function shouldShowWorkspaceConnectionStatus(state: WorkspaceState): bool
state.networkStatus === "offline" ||
state.connectionError !== null ||
state.hasConnectingEnvironment ||
state.hasPendingShellSnapshot ||
(state.hasLoadedShellSnapshot && !state.hasReadyEnvironment)
);
}
Expand All @@ -18,5 +19,8 @@ export function workspaceConnectionStatusLabel(state: WorkspaceState): string {
return `Reconnecting ${state.connectingEnvironments.length} environments`;
}
if (state.connectionError !== null) return state.connectionError;
if (state.hasPendingShellSnapshot) {
return state.hasLoadedShellSnapshot ? "Syncing threads..." : "Loading threads...";
}
return "Not connected";
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import type { ReactNode } from "react";
import { Platform, useColorScheme } from "react-native";

import { renderCompactBrandTitle } from "../../components/CompactBrandTitle";
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";

const SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
Expand All @@ -35,11 +34,10 @@ const SIDEBAR_SCREEN_OPTIONS: SidebarScreenOptions = {
headerShadowVisible: false,
headerShown: true,
headerStyle: { backgroundColor: "transparent" },
headerTitle: renderCompactBrandTitle,
headerTitleStyle: { fontSize: 18, fontWeight: "800" },
headerTransparent: true,
scrollEdgeEffects: SCROLL_EDGE_EFFECTS,
title: "T3 Code",
title: "Threads",
unstable_navigationItemStyle: "editor",
};

Expand Down
109 changes: 109 additions & 0 deletions apps/server/src/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,8 @@ it.layer(NodeServices.layer)("server router seam", (it) => {

assert.equal(response.environment.environmentId, testEnvironmentDescriptor.environmentId);
assert.equal(response.auth.policy, "desktop-managed-local");
assert.equal(response.shellResumeCompletionMarker, true);
assert.equal(response.threadResumeCompletionMarker, true);
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

Expand Down Expand Up @@ -5607,6 +5609,113 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("marks an empty shell catch-up replay as synchronized when requested", () =>
Effect.gen(function* () {
yield* buildAppUnderTest({
layers: {
orchestrationEngine: {
readEvents: () => Stream.empty,
},
},
});

const wsUrl = yield* getWsServerUrl("/ws");
const firstItem = yield* Effect.scoped(
withWsRpcClient(wsUrl, (client) =>
client[ORCHESTRATION_WS_METHODS.subscribeShell]({
afterSequence: 0,
requestCompletionMarker: true,
}).pipe(Stream.runHead),
),
);

assert.deepEqual(Option.getOrThrow(firstItem), { kind: "synchronized" });
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("marks a socket thread snapshot as synchronized when requested", () =>
Effect.gen(function* () {
const thread = makeDefaultOrchestrationReadModel().threads[0]!;
yield* buildAppUnderTest({
layers: {
projectionSnapshotQuery: {
getThreadDetailSnapshot: () =>
Effect.succeed(Option.some({ snapshotSequence: 1, thread })),
},
},
});

const wsUrl = yield* getWsServerUrl("/ws");
const items = yield* Effect.scoped(
withWsRpcClient(wsUrl, (client) =>
client[ORCHESTRATION_WS_METHODS.subscribeThread]({
threadId: defaultThreadId,
requestCompletionMarker: true,
}).pipe(Stream.take(2), Stream.runCollect),
),
);

assert.equal(items[0]?.kind, "snapshot");
assert.deepEqual(items[1], { kind: "synchronized" });
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
);

it.effect("buffers shell events published while the fallback snapshot loads", () =>
Effect.gen(function* () {
const liveEvents = yield* PubSub.unbounded<OrchestrationEvent>();
const deletedEvent = {
sequence: 2,
eventId: EventId.make("event-shell-thread-deleted"),
aggregateKind: "thread",
aggregateId: defaultThreadId,
occurredAt: "2026-01-01T00:00:01.000Z",
commandId: null,
causationEventId: null,
correlationId: null,
metadata: {},
type: "thread.deleted",
payload: {
threadId: defaultThreadId,
deletedAt: "2026-01-01T00:00:01.000Z",
},
} satisfies Extract<OrchestrationEvent, { type: "thread.deleted" }>;

yield* buildAppUnderTest({
layers: {
orchestrationEngine: {
streamDomainEvents: Stream.fromPubSub(liveEvents),
},
projectionSnapshotQuery: {
getShellSnapshot: () =>
Effect.gen(function* () {
yield* Effect.sleep("25 millis");
yield* PubSub.publish(liveEvents, deletedEvent);
return {
snapshotSequence: 1,
projects: [],
threads: [makeDefaultOrchestrationThreadShell()],
updatedAt: "2026-01-01T00:00:00.000Z",
};
}),
},
},
});

const wsUrl = yield* getWsServerUrl("/ws");
const items = yield* Effect.scoped(
withWsRpcClient(wsUrl, (client) =>
client[ORCHESTRATION_WS_METHODS.subscribeShell]({
requestCompletionMarker: true,
}).pipe(Stream.take(3), Stream.runCollect),
),
).pipe(Effect.timeout("2 seconds"));

assert.equal(items[0]?.kind, "snapshot");
assert.equal(items[1]?.kind, "thread-removed");
assert.deepEqual(items[2], { kind: "synchronized" });
}).pipe(Effect.provide(NodeHttpServer.layerTest), TestClock.withLive),
);

it.effect("buffers thread events published while the initial snapshot loads", () =>
Effect.gen(function* () {
const thread = makeDefaultOrchestrationReadModel().threads[0]!;
Expand Down
Loading
Loading