refactor: remove draft agent routes and consolidate terminal output into session model

This commit is contained in:
Mohamed Boudra
2026-03-04 14:17:39 +07:00
parent b21764fd40
commit 92991ffdb8
25 changed files with 634 additions and 317 deletions
@@ -59,7 +59,6 @@ import { useKeyboardShiftStyle } from "@/hooks/use-keyboard-shift-style";
import { shouldClearAgentAttentionOnView } from "@/utils/agent-attention";
import type { DaemonClient } from "@server/client/daemon-client";
import { useExplorerOpenGesture } from "@/hooks/use-explorer-open-gesture";
import { buildHostAgentDraftRoute } from "@/utils/host-routes";
import type { ExplorerCheckoutContext } from "@/stores/panel-store";
const EMPTY_STREAM_ITEMS: StreamItem[] = [];
@@ -529,7 +528,7 @@ function AgentScreenContent({
return;
}
hasRedirectedArchivedAgentRef.current = true;
const route: Href = buildHostAgentDraftRoute(serverId) as Href;
const route: Href = `/h/${encodeURIComponent(serverId)}` as Href;
router.replace(route);
}, [agent?.archivedAt, resolvedAgentId, router, serverId]);
+1 -2
View File
@@ -4,7 +4,6 @@ import { StyleSheet } from "react-native-unistyles";
import { BackHeader } from "@/components/headers/back-header";
import { AgentList } from "@/components/agent-list";
import { useAllAgentsList } from "@/hooks/use-all-agents-list";
import { buildHostAgentDraftRoute } from "@/utils/host-routes";
import { router } from "expo-router";
export function AgentsScreen({ serverId }: { serverId: string }) {
@@ -44,7 +43,7 @@ export function AgentsScreen({ serverId }: { serverId: string }) {
<View style={styles.container}>
<BackHeader
title="All agents"
onBack={() => router.replace(buildHostAgentDraftRoute(serverId) as any)}
onBack={() => router.replace(`/h/${encodeURIComponent(serverId)}` as any)}
/>
<AgentList
agents={sortedAgents}
@@ -306,6 +306,7 @@ function WorkspaceScreenContent({
const workspaceHeader = workspaceDescriptor
? resolveWorkspaceHeader({ workspace: workspaceDescriptor })
: null;
const isWorkspaceHeaderLoading = workspaceHeader === null;
const isGitCheckout = checkoutQuery.data?.isGit ?? false;
const mobileView = usePanelStore((state) => state.mobileView);
@@ -417,21 +418,6 @@ function WorkspaceScreenContent({
if (!normalized || !persistenceKey) {
return;
}
if (normalized.startsWith("draft_")) {
const tabId = openDraftTab({
serverId: normalizedServerId,
workspaceId: normalizedWorkspaceId,
draftId: normalized,
});
if (tabId) {
focusTab({
serverId: normalizedServerId,
workspaceId: normalizedWorkspaceId,
tabId,
});
}
return;
}
if (normalized.startsWith("file_")) {
const path = normalized.slice("file_".length).trim();
if (!path) {
@@ -529,6 +515,38 @@ function WorkspaceScreenContent({
[normalizedServerId, normalizedWorkspaceId, router]
);
const emptyWorkspaceSeedRef = useRef<string | null>(null);
useEffect(() => {
if (!persistenceKey) {
return;
}
if (tabs.length > 0) {
emptyWorkspaceSeedRef.current = null;
return;
}
const workspaceKey = `${normalizedServerId}:${normalizedWorkspaceId}`;
if (emptyWorkspaceSeedRef.current === workspaceKey) {
return;
}
emptyWorkspaceSeedRef.current = workspaceKey;
const draftId = generateDraftId();
const tabId = openDraftTab({
serverId: normalizedServerId,
workspaceId: normalizedWorkspaceId,
draftId,
});
if (tabId) {
navigateToTabId(tabId);
}
}, [
navigateToTabId,
normalizedServerId,
normalizedWorkspaceId,
openDraftTab,
persistenceKey,
tabs.length,
]);
const handleOpenFileFromExplorer = useCallback(
(filePath: string) => {
if (isMobile) {
@@ -1025,12 +1043,21 @@ function WorkspaceScreenContent({
<>
<SidebarMenuToggle />
<View style={styles.headerTitleContainer}>
<Text style={styles.headerTitle} numberOfLines={1}>
{workspaceHeader ? workspaceHeader.title : "Loading workspace…"}
</Text>
<Text style={styles.headerProjectTitle} numberOfLines={1}>
{workspaceHeader ? workspaceHeader.subtitle : "Awaiting workspace descriptor"}
</Text>
{isWorkspaceHeaderLoading ? (
<>
<View style={styles.headerTitleSkeleton} />
<View style={styles.headerProjectTitleSkeleton} />
</>
) : (
<>
<Text style={styles.headerTitle} numberOfLines={1}>
{workspaceHeader.title}
</Text>
<Text style={styles.headerProjectTitle} numberOfLines={1}>
{workspaceHeader.subtitle}
</Text>
</>
)}
</View>
</>
}
@@ -1326,6 +1353,22 @@ const styles = StyleSheet.create((theme) => ({
fontSize: theme.fontSize.base,
flexShrink: 1,
},
headerTitleSkeleton: {
width: 190,
maxWidth: "45%",
height: 22,
borderRadius: theme.borderRadius.full,
backgroundColor: theme.colors.surface3,
opacity: 0.25,
},
headerProjectTitleSkeleton: {
width: 300,
maxWidth: "45%",
height: 22,
borderRadius: theme.borderRadius.full,
backgroundColor: theme.colors.surface3,
opacity: 0.18,
},
headerRight: {
flexDirection: "row",
alignItems: "center",