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
5 changes: 5 additions & 0 deletions apps/mobile/src/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
import { ConnectOnboardingRouteScreen } from "./features/cloud/ConnectOnboardingRouteScreen";
import { AttachmentFileScreen } from "./features/files/AttachmentFileScreen";
import { ProjectArtifactsScreen } from "./features/files/ProjectArtifactsScreen";
import { ThreadFilesTreeScreen, ThreadFileScreen } from "./features/files/ThreadFilesRouteScreen";
import { AdaptiveWorkspaceLayout } from "./features/layout/AdaptiveWorkspaceLayout";
import {
Expand Down Expand Up @@ -768,6 +769,10 @@ const RootStackConfig = createWorkspaceStackNavigator({
linking: `${THREAD_LINKING_PREFIX}/review-comment`,
options: sheetRoute({ detent: 0.55, android: "fullScreen" }),
}),
ProjectArtifacts: createNativeStackScreen({
screen: ProjectArtifactsScreen,
options: pageRoute({ header: "solid" }),
}),
ThreadFiles: createNativeStackScreen({
screen: ThreadFilesTreeScreen,
linking: `${THREAD_LINKING_PREFIX}/files`,
Expand Down
134 changes: 134 additions & 0 deletions apps/mobile/src/features/files/ProjectArtifactsScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { useAtomValue } from "@effect/atom-react";
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import {
createEnvironmentRpcCommand,
createEnvironmentRpcSubscriptionAtomFamily,
} from "@t3tools/client-runtime/state/runtime";
import {
AuthFilesystemReadScope,
WS_METHODS,
type ScopedProjectRef,
type ThreadId,
} from "@t3tools/contracts";
import { useGT } from "gt-react-native";
import { View } from "react-native";

import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
import { AppBar } from "../../components/ui/AppBar";
import { SymbolView } from "../../components/ui/AppSymbol";
import { AppText } from "../../components/ui/AppText";
import { RowPressable } from "../../components/ui/RowPressable";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { useUnadjustedBottomInset } from "../../components/ui/useBarInset";
import { connectionAtomRuntime } from "../../connection/runtime";
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
import { useProject } from "../../state/entities";
import { useEnvironmentQuery } from "../../state/query";
import { useEnvironmentScope, useEnvironmentScopeDenied } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
import { basename, fileRoutePathSegments } from "./filePath";

const listArtifacts = createEnvironmentRpcSubscriptionAtomFamily(connectionAtomRuntime, {
label: "environment-data:project-artifacts",
tag: WS_METHODS.projectArtifactsSubscribe,
});
const removeArtifact = createEnvironmentRpcCommand(connectionAtomRuntime, {
label: "project-artifacts:remove",
tag: WS_METHODS.projectArtifactsRemove,
});

export function ProjectArtifactsScreen({
route,
}: StaticScreenProps<ScopedProjectRef & { readonly threadId: ThreadId }>) {
const { environmentId, projectId, threadId } = route.params;
const navigation = useNavigation();
const gt = useGT();
const bottomInset = useUnadjustedBottomInset();
const project = useProject({ environmentId, projectId });
const canRead = useEnvironmentScope(environmentId, AuthFilesystemReadScope);
const readDenied = useEnvironmentScopeDenied(environmentId, AuthFilesystemReadScope);
const canRemove = useAtomValue(removeArtifact.permissionAtom(environmentId));
const remove = useAtomCommand(removeArtifact);
const list = useEnvironmentQuery(
canRead ? listArtifacts({ environmentId, input: { projectId } }) : null,
);

return (
<View className="flex-1">
<AppBar
title={gt("Artifacts")}
subtitle={project?.title}
onBack={() => navigation.goBack()}
/>
<ScreenContent>
<NativeScrollView
className="flex-1"
contentInsetAdjustmentBehavior="automatic"
contentContainerStyle={{ paddingHorizontal: 12, paddingBottom: bottomInset + 12 }}
>
{readDenied || list.error !== null || list.data?.length === 0 ? (
<AppText className="p-4 text-sm text-foreground-muted">
{readDenied
? gt("File access is required.")
: (list.error ?? gt("No saved artifacts."))}
</AppText>
) : list.data === null || project === null ? (
<AppActivityIndicator className="my-8" />
) : (
list.data.map((artifact) => {
const title = artifact.label ?? basename(artifact.path);
return (
<View
key={artifact.id}
className="flex-row items-center border-b border-border-subtle"
>
<RowPressable
accessibilityRole="button"
className="min-h-11 flex-1 flex-row items-center gap-3 px-3 py-2"
onPress={() =>
navigation.dispatch(
StackActions.push("ThreadFile", {
environmentId,
threadId,
cwd: project.workspaceRoot,
projectName: project.title,
path: fileRoutePathSegments(artifact.path),
}),
)
}
>
<SymbolView name="doc" size={18} tintColorClassName="foreground-muted" />
<View className="min-w-0 flex-1">
<AppText className="text-sm font-t3-medium" numberOfLines={1}>
{title}
</AppText>
<AppText
className="text-xs text-foreground-muted"
numberOfLines={1}
ellipsizeMode="middle"
>
{artifact.description ?? artifact.path}
</AppText>
</View>
</RowPressable>
{canRemove ? (
<RowPressable
accessibilityRole="button"
accessibilityLabel={gt("Remove artifact {name}", { name: title })}
className="size-11 items-center justify-center"
onPress={() =>
void remove({ environmentId, input: { projectId, id: artifact.id } })
}
>
<SymbolView name="trash" size={17} tintColorClassName="foreground-muted" />
</RowPressable>
) : null}
</View>
);
})
)}
</NativeScrollView>
</ScreenContent>
</View>
);
}
19 changes: 12 additions & 7 deletions apps/mobile/src/features/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import type { PendingNewTask } from "../../state/use-pending-new-tasks";
import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
import {
ThreadListV2PendingRow,
ThreadListV2AgentSectionHeader,
ThreadListV2Row,
THREAD_ROW_VIEWABILITY,
ThreadListV2SettledShelfHeader,
Expand Down Expand Up @@ -399,7 +400,8 @@ export function HomeScreen(props: HomeScreenProps) {
toggleSnoozedShelf,
toggleWorkingShelf,
} = useThreadListV2ShelfPreferences();
const now = useThreadListNow(props.threads);
const agentThreads = useAtomValue(steadyThreadShells.quietThreadShellsAtom);
const now = useThreadListNow(agentThreads);
const listEnvironments = useAtomValue(threadListEnvironmentsAtom);
const {
providersByEnvironmentId,
Expand All @@ -421,10 +423,10 @@ export function HomeScreen(props: HomeScreenProps) {
contentOnlyThreadKeys,
olderSettledShelf,
selectedRowKey,
setFamilyExpanded,
toggleAgentSection,
} = useThreadListV2({
familyThreads: useAtomValue(steadyThreadShells.quietThreadShellsAtom),
delegatedUnderParent: useAtomValue(steadyThreadShells.delegatedUnderParentAtom),
agentThreads,
projects: projectScopes,
openThreadKey: activeNewTask ? null : (primaryColumn?.selectedThreadKey ?? null),
threads: props.threads,
pendingTasks: props.pendingTasks,
Expand Down Expand Up @@ -534,6 +536,9 @@ export function HomeScreen(props: HomeScreenProps) {
/>
);
}
if (item.type === "v2-agent-section") {
return <ThreadListV2AgentSectionHeader item={item} onToggle={toggleAgentSection} />;
}
const thread = item.item.thread;
return (
<ThreadListV2Row
Expand All @@ -542,9 +547,9 @@ export function HomeScreen(props: HomeScreenProps) {
fullSwipeWidth={fullSwipeWidth}
onNewThreadOnBranch={props.onNewThreadOnBranch}
thread={thread}
family={item.family}
agentCount={item.agentCount}
agentRow={item.agentRow}
listVisible={props.visible}
onToggleFamily={setFamilyExpanded}
variant={item.item.variant}
hasQueuedMessages={item.hasQueuedMessages}
snoozed={item.item.snoozed}
Expand Down Expand Up @@ -588,7 +593,7 @@ export function HomeScreen(props: HomeScreenProps) {
pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)}
reorderSupported={
!item.family?.depth &&
!item.agentRow &&
(item.item.pinned
? pinReorderEnvironmentIds.has(thread.environmentId)
: !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId))
Expand Down
9 changes: 9 additions & 0 deletions apps/mobile/src/features/threads/ThreadHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function ThreadHeader(props: {
readonly hasThreadCwd: boolean;
readonly inspectorMode: ThreadInspectorMode | null;
readonly onOpenFilesInspector: () => void;
readonly onOpenArtifacts?: (() => void) | undefined;
}) {
const gt = useGT();
const m = useMessages();
Expand All @@ -44,6 +45,14 @@ export function ThreadHeader(props: {
},
]
: [];
if (props.onOpenArtifacts) {
actions.push({
accessibilityLabel: gt("Artifacts"),
icon: "archivebox",
onPress: props.onOpenArtifacts,
separateBackground: false,
});
}
const menus = [gitMenu, terminalMenu].filter((menu): menu is AppBarMenu => menu !== null);

return (
Expand Down
18 changes: 11 additions & 7 deletions apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { WorkspaceListHeader } from "../layout/workspace/WorkspaceListHeader";
import { WorkspaceSidebarColumn } from "../layout/workspace/WorkspaceSidebarColumn";
import {
ThreadListV2PendingRow,
ThreadListV2AgentSectionHeader,
ThreadListV2Row,
THREAD_ROW_VIEWABILITY,
ThreadListV2SettledShelfHeader,
Expand Down Expand Up @@ -257,7 +258,8 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
toggleSnoozedShelf,
toggleWorkingShelf,
} = useThreadListV2ShelfPreferences();
const now = useThreadListNow(threads);
const agentThreads = useAtomValue(steadyThreadShells.quietThreadShellsAtom);
const now = useThreadListNow(agentThreads);
const listEnvironments = useAtomValue(threadListEnvironmentsAtom);
const {
providersByEnvironmentId,
Expand All @@ -279,10 +281,10 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
contentOnlyThreadKeys,
olderSettledShelf,
selectedRowKey,
setFamilyExpanded,
toggleAgentSection,
} = useThreadListV2({
familyThreads: useAtomValue(steadyThreadShells.quietThreadShellsAtom),
delegatedUnderParent: useAtomValue(steadyThreadShells.delegatedUnderParentAtom),
agentThreads,
projects: projectScopes,
openThreadKey: activeNewTask ? null : props.selectedThreadKey,
threads: launchingThreads,
pendingTasks,
Expand Down Expand Up @@ -421,16 +423,18 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
/>
);
}
case "v2-agent-section":
return <ThreadListV2AgentSectionHeader item={item} onToggle={toggleAgentSection} />;
case "v2-thread": {
const thread = item.item.thread;
const scopeKey = scopedProjectKey(thread.environmentId, thread.projectId);
return (
<ThreadListV2Row
onNewThreadOnBranch={props.onNewThreadOnBranch}
thread={thread}
family={item.family}
agentCount={item.agentCount}
agentRow={item.agentRow}
listVisible={props.visible}
onToggleFamily={setFamilyExpanded}
variant={item.item.variant}
hasQueuedMessages={item.hasQueuedMessages}
snoozed={item.item.snoozed}
Expand Down Expand Up @@ -481,7 +485,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)}
reorderSupported={
!item.family?.depth &&
!item.agentRow &&
(item.item.pinned
? pinReorderEnvironmentIds.has(thread.environmentId)
: !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId))
Expand Down
12 changes: 12 additions & 0 deletions apps/mobile/src/features/threads/ThreadRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,18 @@ function ThreadRouteContent(
hasThreadCwd={selectedThreadCwd !== null}
inspectorMode={inspectorMode}
onOpenFilesInspector={handleOpenFilesInspector}
onOpenArtifacts={
selectedThreadProject === null
? undefined
: () =>
navigation.dispatch(
StackActions.push("ProjectArtifacts", {
environmentId: selectedThread.environmentId,
projectId: selectedThreadProject.id,
threadId: selectedThread.id,
}),
)
}
onReturnToThread={props.onReturnToThread}
/>
)
Expand Down
Loading
Loading