Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

feat(workflows): add semantic session flows

Rahmanbbe2ec5da4de
diff --git a/docs/generated/MCP-CATALOG.md b/docs/generated/MCP-CATALOG.md
index 7ba7d4a9..6bd922d7 100644
--- a/docs/generated/MCP-CATALOG.md
+++ b/docs/generated/MCP-CATALOG.md
@@ -4,21 +4,21 @@
## Full MSO catalog
-<!-- mcp-toolset: server=1.14.4 version=2026.09.15.3 tools=108 read=51 write=35 exec=22 -->
+<!-- mcp-toolset: server=1.14.4 version=2026.09.15.3 tools=109 read=52 write=35 exec=22 -->
| Fact | Current source value |
|---|---:|
| MCP server | `1.14.4` |
| Toolset | `2026.09.15.3` |
| Toolset changed at | `2026-09-15T03:35:00+07:00` |
-| Transport tools | **110** |
-| Model/operator tools | **108** |
-| Read | **51** |
+| Transport tools | **111** |
+| Model/operator tools | **109** |
+| Read | **52** |
| Write | **35** |
| Exec | **22** |
| App-only bridges | **2** |
-### Read (51)
+### Read (52)
- `a2a_agent_discover`
- `a2a_agents_list`
@@ -26,6 +26,7 @@
- `agent_memory_read`
- `agent_memory_search`
- `agent_session_current`
+- `agent_session_flow`
- `agent_session_resume`
- `agent_sessions_list`
- `apps_list`
@@ -142,20 +143,20 @@
## ChatGPT model profile
-<!-- mcp-chatgpt-profile: server=1.14.4 version=2026.09.15.3 tools=108 read=51 write=35 exec=22 app-only=2 total=110 -->
+<!-- mcp-chatgpt-profile: server=1.14.4 version=2026.09.15.3 tools=109 read=52 write=35 exec=22 app-only=2 total=111 -->
The ChatGPT profile automatically projects the complete MSO-owned generic model/operator catalog. OAuth scope is still enforced independently; app-only compatibility bridges stay app-only, and project-owned MCP tool names remain dynamic data behind the generic project bridge.
| Fact | Current source value |
|---|---:|
-| ChatGPT transport tools | **110** |
-| ChatGPT model/operator tools | **108** |
-| Read | **51** |
+| ChatGPT transport tools | **111** |
+| ChatGPT model/operator tools | **109** |
+| Read | **52** |
| Write | **35** |
| Exec | **22** |
| App-only bridges | **2** |
-### ChatGPT read (51)
+### ChatGPT read (52)
- `a2a_agent_discover`
- `a2a_agents_list`
@@ -163,6 +164,7 @@ The ChatGPT profile automatically projects the complete MSO-owned generic model/
- `agent_memory_read`
- `agent_memory_search`
- `agent_session_current`
+- `agent_session_flow`
- `agent_session_resume`
- `agent_sessions_list`
- `apps_list`
diff --git a/frontend/slices/workflows/app.tsx b/frontend/slices/workflows/app.tsx
index a28cef4f..22c18679 100644
--- a/frontend/slices/workflows/app.tsx
+++ b/frontend/slices/workflows/app.tsx
@@ -74,15 +74,16 @@ export default function WorkflowsApp(props: AppProps) {
const connect = (source: string, target: string, sourceHandle?: string) => { if (!graph || graph.edges.some((edge) => edge.source === source && edge.target === target && edge.sourceHandle === sourceHandle)) return; mutate({ ...graph, edges: [...graph.edges, { id: `edge-${crypto.randomUUID().slice(0, 8)}`, source, target, ...(sourceHandle ? { sourceHandle } : {}) }] }); };
const openNode = async (id: string) => { if (!graph) return; const resolved = await resolveNode(graph.id, id); openWindow("files-manager", resolved.name, undefined, { path: resolved.path }, { multi: true }); };
const openSessionTerminal = () => { if (!sessionView) return; openWindow("os-terminal", "Terminal", undefined, { initialCwd: sessionView.session.cwd || "~" }, { multi: true }); };
+ const openSessionCode = (path: string) => { const name = path.split("/").filter(Boolean).at(-1) || "Code"; openWindow("code-editor", name, undefined, { path }, { multi: true }); };
const chooseNode = (id: string | null) => { setSelected(id); if (!id) return; setPanel("inspector"); if (overlayPane) setDetailsOpen(true); };
- const chooseSessionNode = (id: string | null) => { setSessionSelected(id); if (!id) return; const target = sessionView?.graph.nodes.find((item) => item.id === id); if (target?.config.terminalContext === true) { setDetailsOpen(false); openSessionTerminal(); return; } if (overlayPane) setDetailsOpen(true); };
+ const chooseSessionNode = (id: string | null) => { setSessionSelected(id); if (id && overlayPane) setDetailsOpen(true); };
const tidy = () => graph && mutate({ ...graph, nodes: tidyWorkflowNodes(graph) });
const toggleLibrary = () => overlayPane ? setLibraryOpen(true) : setShowLibrary((value) => !value);
const toggleDetails = () => overlayPane ? setDetailsOpen(true) : setShowDetails((value) => !value);
const automationLibrary = <WorkflowLibrary graphs={graphs} activeId={graph?.id} search={search} onSearch={setSearch} onSelect={(id) => void wrap(() => selectGraph(id))} onBlank={async () => { await createBlank(); }} onTemplate={async (id) => { await createTemplate(id); }} onAI={async (definition) => { await createAI(definition); }}/>;
const library = <div className="flex h-full min-h-0 flex-col"><div className="grid grid-cols-2 gap-1 border-b p-2">{(["automations", "sessions"] as const).map((mode) => <button key={mode} type="button" className={`rounded-md px-2 py-1.5 text-xs capitalize ${libraryMode === mode ? "bg-accent font-semibold" : "text-muted-foreground hover:bg-accent/60"}`} onClick={() => setLibraryMode(mode)}>{mode}</button>)}</div><div className="min-h-0 flex-1">{libraryMode === "automations" ? automationLibrary : <WorkflowSessionLibrary activeId={sessionView?.session.id} onSelect={(id) => void wrap(() => selectSession(id))}/>}</div></div>;
- const details = libraryMode === "sessions" && sessionView ? <WorkflowSessionDetails view={sessionView} node={sessionNode} onOpenTerminal={openSessionTerminal}/> : graph ? <WorkflowDetails graph={graph} graphs={graphs} node={node} run={run} panel={panel} onPanel={setPanel} onNode={updateNode} onDeleteNode={(id) => deleteNodes([id])} onGraph={mutate} onRunSelect={(selectedRun) => { setRun(selectedRun); setPanel("run"); }} onRestored={(next) => { setGraph(next); setDirty(false); void listGraphs().then(setGraphs); }}/> : null;
+ const details = libraryMode === "sessions" && sessionView ? <WorkflowSessionDetails view={sessionView} node={sessionNode} onOpenTerminal={openSessionTerminal} onOpenCode={openSessionCode}/> : graph ? <WorkflowDetails graph={graph} graphs={graphs} node={node} run={run} panel={panel} onPanel={setPanel} onNode={updateNode} onDeleteNode={(id) => deleteNodes([id])} onGraph={mutate} onRunSelect={(selectedRun) => { setRun(selectedRun); setPanel("run"); }} onRestored={(next) => { setGraph(next); setDirty(false); void listGraphs().then(setGraphs); }}/> : null;
const toolbarItems: ToolbarItem[] = [
{ id: "library", label: "Workflow library", icon: PanelLeft, onClick: toggleLibrary, primary: true },
{ id: "refresh", label: "Refresh", icon: RefreshCw, onClick: () => void wrap(async () => { if (libraryMode === "sessions") await refreshSession(); else await load(undefined, true); }), disabled: busy },
@@ -100,15 +101,15 @@ export default function WorkflowsApp(props: AppProps) {
return <div ref={appRef} data-slot="workflows-feature" className="@container h-full min-h-0 min-w-0">
<AppFrame safeArea={false} className="h-full min-w-0" toolbar={<div className="flex h-11 min-w-0 items-center gap-1 px-2 @min-[700px]:gap-2 @min-[700px]:px-3"><Workflow className="hidden size-4 shrink-0 @min-[700px]:block"/><span className="hidden shrink-0 text-sm font-semibold @min-[700px]:inline">Workflows</span>{libraryMode === "sessions" ? <Badge variant="outline" className="shrink-0"><Activity className="mr-1 size-3"/>Session</Badge> : dirty ? <Badge variant="outline" className="hidden shrink-0 @min-[520px]:inline-flex">Unsaved</Badge> : null}{libraryMode === "automations" && graph ? <Input aria-label="Workflow name" className="h-8 min-w-[7rem] max-w-56 flex-1 @max-[600px]:max-w-none" value={graph.name} onChange={(event) => mutate({ ...graph, name: event.target.value })}/> : <div className="min-w-0 flex-1 truncate text-sm font-medium">{headerTitle || (libraryMode === "sessions" ? "Sessions" : "Workflows")}</div>}{libraryMode === "automations" ? <WorkflowCreateDialog compact={overlayPane} onBlank={async () => { await createBlank(); }} onTemplate={async (id) => { await createTemplate(id); }} onAI={async (definition) => { await createAI(definition); }}/> : null}<ResponsiveToolbar items={toolbarItems} compact={overlayPane} className="ml-auto shrink-0"/></div>}>
- <div className={`grid h-full min-h-0 min-w-0 ${showLibraryPanel ? "grid-cols-[220px_minmax(0,1fr)]" : "grid-cols-1"}`}>
+ <div className={`grid h-full min-h-0 min-w-0 ${showLibraryPanel ? "grid-cols-[300px_minmax(0,1fr)] @min-[1200px]:grid-cols-[340px_minmax(0,1fr)]" : "grid-cols-1"}`}>
{showLibraryPanel ? <aside className="min-h-0 min-w-0 border-r">{library}</aside> : null}
<main className="flex min-h-0 min-w-0 overflow-hidden">
{libraryMode === "automations" ? graph ? <div className="flex min-h-0 min-w-0 flex-1 flex-col"><div className="flex min-h-10 min-w-0 shrink-0 flex-wrap items-center gap-1.5 border-b px-2 py-1 @min-[520px]:flex-nowrap @min-[520px]:gap-2"><label className="flex shrink-0 items-center gap-1.5 text-[10px] font-medium"><Switch checked={graph.status === "active"} disabled={graph.status === "archived"} onCheckedChange={(checked) => mutate({ ...graph, status: checked ? "active" : "draft" })}/><span>Active</span></label><select aria-label="Workflow lifecycle" className="h-7 min-w-0 max-w-24 rounded border bg-background px-2 text-xs" value={graph.status} onChange={(event) => mutate({ ...graph, status: event.target.value as WorkflowGraph["status"] })}><option value="draft">Draft</option><option value="active">Active</option><option value="archived">Archived</option></select><WorkflowNodePalette onAdd={addNode}/><span className="hidden min-w-0 truncate text-[10px] text-muted-foreground @min-[900px]:inline">Drag output → input. V Select · H Pan · +/- Zoom · F Fit · Space temporary pan.</span>{message ? <span className="w-full min-w-0 truncate text-[11px] text-muted-foreground @min-[520px]:ml-auto @min-[520px]:w-auto @min-[520px]:max-w-72">{message}</span> : null}</div><div className="min-h-0 min-w-0 flex-1 overflow-hidden"><WorkflowCanvas key={graph.id} graph={graph} selectedId={selected} onSelect={chooseNode} nodeStates={runStates} edgeStates={runEdgeStates} onOpen={(id) => void openNode(id)} onConnect={connect} onMove={(id, position) => mutate({ ...graph, nodes: graph.nodes.map((item) => item.id === id ? { ...item, position } : item) })} onDeleteNodes={deleteNodes} onDeleteEdges={deleteEdges} onTidy={tidy}/></div></div> : <div className="flex h-full min-w-0 flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground">Create or select an automation.</div>
- : sessionView ? <div className="flex min-h-0 min-w-0 flex-1 flex-col"><div className="flex min-h-10 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground [@media(max-height:520px)]:hidden"><span className="font-medium text-foreground">{sessionView.session.label}</span><span>read-only</span><span>·</span><span>{sessionView.shownEvents}/{sessionView.totalEvents} events</span>{message ? <span className="ml-auto truncate">{message}</span> : null}</div><div className="min-h-0 min-w-0 flex-1 overflow-hidden"><WorkflowCanvas key={sessionView.graph.revision} graph={sessionView.graph} selectedId={sessionSelected} onSelect={chooseSessionNode} onConnect={() => undefined} onMove={() => undefined} readOnly/></div></div> : <div className="flex h-full min-w-0 flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground">Select a session to inspect its execution graph.</div>}
+ : sessionView ? <div className="flex min-h-0 min-w-0 flex-1 flex-col"><div className="flex min-h-10 shrink-0 items-center gap-2 border-b px-3 text-[11px] text-muted-foreground [@media(max-height:520px)]:hidden"><span className="font-medium text-foreground">{sessionView.session.label}</span><span>read-only</span><span>·</span><span>{sessionView.steps.length} steps</span><span>·</span><span>{sessionView.shownEvents}/{sessionView.totalEvents} actions</span>{message ? <span className="ml-auto truncate">{message}</span> : null}</div><div className="min-h-0 min-w-0 flex-1 overflow-hidden"><WorkflowCanvas key={sessionView.graph.revision} graph={sessionView.graph} selectedId={sessionSelected} onSelect={chooseSessionNode} onConnect={() => undefined} onMove={() => undefined} readOnly/></div></div> : <div className="flex h-full min-w-0 flex-1 items-center justify-center px-4 text-center text-sm text-muted-foreground">Select a session to inspect its semantic execution flow.</div>}
{showDetailsPanel ? <aside className="w-[320px] shrink-0 border-l @min-[1200px]:w-[360px]">{details}</aside> : null}
</main>
</div>
- {overlayPane ? <><ResponsiveDialog open={libraryOpen} onOpenChange={setLibraryOpen} variant="panel" size="lg" mobileVariant="drawer-right" sheetSide="left"><ResponsiveDialog.Header><ResponsiveDialog.Title>Workflows</ResponsiveDialog.Title><ResponsiveDialog.Description>Switch between reusable automations and recorded sessions.</ResponsiveDialog.Description></ResponsiveDialog.Header><ResponsiveDialog.Body className="p-0">{library}</ResponsiveDialog.Body></ResponsiveDialog><ResponsiveDialog open={detailsOpen && Boolean(libraryMode === "sessions" ? sessionView : graph)} onOpenChange={setDetailsOpen} variant="panel" size="lg" mobileVariant="drawer-right" sheetSide="right"><ResponsiveDialog.Header><ResponsiveDialog.Title>{libraryMode === "sessions" ? sessionNode?.name ?? sessionView?.session.label ?? "Session details" : node?.name ?? graph?.name ?? "Workflow details"}</ResponsiveDialog.Title><ResponsiveDialog.Description>{libraryMode === "sessions" ? "Inspect recorded tool activity without exposing internal session IDs." : "Inspect configuration, runs, versions, variables, and the directory without shrinking the canvas."}</ResponsiveDialog.Description></ResponsiveDialog.Header><ResponsiveDialog.Body className="p-0">{details}</ResponsiveDialog.Body></ResponsiveDialog></> : null}
+ {overlayPane ? <><ResponsiveDialog open={libraryOpen} onOpenChange={setLibraryOpen} variant="panel" size="lg" mobileVariant="drawer-right" sheetSide="left"><ResponsiveDialog.Header><ResponsiveDialog.Title>Workflows</ResponsiveDialog.Title><ResponsiveDialog.Description>Switch between reusable automations and recorded sessions.</ResponsiveDialog.Description></ResponsiveDialog.Header><ResponsiveDialog.Body className="p-0">{library}</ResponsiveDialog.Body></ResponsiveDialog><ResponsiveDialog open={detailsOpen && Boolean(libraryMode === "sessions" ? sessionView : graph)} onOpenChange={setDetailsOpen} variant="panel" size="lg" mobileVariant="drawer-right" sheetSide="right"><ResponsiveDialog.Header><ResponsiveDialog.Title>{libraryMode === "sessions" ? sessionNode?.name ?? sessionView?.session.label ?? "Session details" : node?.name ?? graph?.name ?? "Workflow details"}</ResponsiveDialog.Title><ResponsiveDialog.Description>{libraryMode === "sessions" ? "Inspect semantic steps, grouped actions, code, and execution receipts without exposing internal session IDs." : "Inspect configuration, runs, versions, variables, and the directory without shrinking the canvas."}</ResponsiveDialog.Description></ResponsiveDialog.Header><ResponsiveDialog.Body className="p-0">{details}</ResponsiveDialog.Body></ResponsiveDialog></> : null}
</AppFrame>
</div>;
}
diff --git a/frontend/slices/workflows/components/workflow-canvas.tsx b/frontend/slices/workflows/components/workflow-canvas.tsx
index 1154f2b5..85962662 100644
--- a/frontend/slices/workflows/components/workflow-canvas.tsx
+++ b/frontend/slices/workflows/components/workflow-canvas.tsx
@@ -20,17 +20,24 @@ function sourceHandles(node: WorkflowGraphNode): Array<string | undefined> {
const canError=(node:WorkflowGraphNode)=>!["manual","schedule","webhook","output"].includes(node.type);
const canInput=(node:WorkflowGraphNode)=>!["manual","schedule","webhook"].includes(node.type);
const canOutput=(node:WorkflowGraphNode)=>node.type!=="output";
+function nodeMetrics(node:WorkflowGraphNode){
+ const semantic=node.config.sessionStep===true||node.config.sessionRoot===true,handles=sourceHandles(node);
+ return {width:semantic?250:200,height:semantic?104:Math.max(78,48+Math.max(handles.length,canError(node)?2:1)*20)};
+}
function WorkflowNodeCard({data,selected}:NodeProps<FlowNode>){
- const{node,state}=data,handles=sourceHandles(node),height=Math.max(78,48+Math.max(handles.length,canError(node)?2:1)*20);
- return <div className={cn("relative w-[200px] rounded-xl border bg-card px-3 py-3 shadow-sm transition-shadow",selected&&"ring-2 ring-ring shadow-md",state==="failed"&&"border-destructive ring-1 ring-destructive",state==="running"&&"border-primary ring-1 ring-primary",["skipped","blocked"].includes(state??"")&&"opacity-55",node.disabled&&"opacity-50")} style={{minHeight:height}}>
+ const{node,state}=data,handles=sourceHandles(node),metrics=nodeMetrics(node),semantic=node.config.sessionStep===true||node.config.sessionRoot===true;
+ const actionCount=typeof node.config.actionCount==="number"?node.config.actionCount:undefined,summary=typeof node.config.summary==="string"?node.config.summary:undefined;
+ return <div className={cn("relative rounded-xl border bg-card px-3 py-3 shadow-sm transition-shadow",semantic?"w-[250px]":"w-[200px]",selected&&"ring-2 ring-ring shadow-md",state==="failed"&&"border-destructive ring-1 ring-destructive",state==="running"&&"border-primary ring-1 ring-primary",["skipped","blocked"].includes(state??"")&&"opacity-55",node.disabled&&"opacity-50")} style={{minHeight:metrics.height}}>
{canInput(node)?<Handle type="target" position={Position.Left} id="input" className="!size-3.5 !border-2 !border-background !bg-muted-foreground"/>:null}
- <div className="truncate text-xs font-semibold">{node.name}</div><div className="mt-1 text-[10px] uppercase tracking-wide text-muted-foreground">{node.type.replaceAll("_"," ")}{state?` · ${state}`:""}</div>
+ <div className={cn("text-xs font-semibold",semantic?"line-clamp-2 leading-4":"truncate")}>{node.name}</div>
+ <div className="mt-1 flex items-center gap-1.5 text-[10px] uppercase tracking-wide text-muted-foreground"><span>{node.type.replaceAll("_"," ")}{state?` · ${state}`:""}</span>{actionCount!==undefined?<span className="rounded bg-muted px-1.5 py-0.5 normal-case tracking-normal">{actionCount} actions</span>:null}</div>
+ {summary?<p className="mt-1.5 line-clamp-2 text-[10px] leading-4 text-muted-foreground">{summary}</p>:null}
{canOutput(node)?handles.map((handle,index)=><div key={handle??"output"} className="absolute right-0 flex translate-x-1/2 items-center" style={{top:38+index*20}}>{handle?<span className="pointer-events-none absolute right-4 whitespace-nowrap pr-1 text-[8px] text-muted-foreground">{handle}</span>:null}<Handle type="source" position={Position.Right} id={handle??"output"} className="!relative !right-auto !top-auto !size-3.5 !translate-x-0 !translate-y-0 !border-2 !border-background !bg-muted-foreground"/></div>):null}
{canError(node)?<Handle type="source" position={Position.Bottom} id="error" className="!size-3 !border-2 !border-background !bg-destructive"/>:null}
</div>;
}
const nodeTypes={workflow:WorkflowNodeCard};
-function toNodes(graph:WorkflowGraph,selectedId:string|null,nodeStates?:ReadonlyMap<string,WorkflowGraphNodeState>):FlowNode[]{return graph.nodes.map((node)=>{const handles=sourceHandles(node),height=Math.max(78,48+Math.max(handles.length,canError(node)?2:1)*20);return{id:node.id,type:"workflow",position:node.position,width:200,height,selected:node.id===selectedId,data:{node,state:nodeStates?.get(node.id)}};});}
+function toNodes(graph:WorkflowGraph,selectedId:string|null,nodeStates?:ReadonlyMap<string,WorkflowGraphNodeState>):FlowNode[]{return graph.nodes.map((node)=>{const metrics=nodeMetrics(node);return{id:node.id,type:"workflow",position:node.position,width:metrics.width,height:metrics.height,selected:node.id===selectedId,data:{node,state:nodeStates?.get(node.id)}};});}
function edgeVisual(edge:WorkflowGraph["edges"][number],state:WorkflowGraphRunEdgeState|undefined,nodeStates?:ReadonlyMap<string,WorkflowGraphNodeState>){
const running=nodeStates?.get(edge.source)==="running"||nodeStates?.get(edge.target)==="running",error=edge.sourceHandle==="error",branch=Boolean(edge.sourceHandle&&edge.sourceHandle!=="output"),disabled=state==="disabled";
const stroke=error?"var(--destructive)":running?"var(--accent)":state==="enabled"?"var(--success)":"var(--sep-strong)";
@@ -41,7 +48,7 @@ function minimapColor(node:FlowNode){const state=node.data.state;if(state==="run
export function WorkflowCanvas({graph,selectedId,onSelect,onMove,onConnect,nodeStates,edgeStates,onOpen,onDeleteNodes,onDeleteEdges,onTidy,readOnly=false}:{graph:WorkflowGraph;selectedId:string|null;onSelect:(id:string|null)=>void;onMove:(id:string,position:{x:number;y:number})=>void;onConnect:(source:string,target:string,sourceHandle?:string)=>void;nodeStates?:ReadonlyMap<string,WorkflowGraphNodeState>;edgeStates?:ReadonlyMap<string,WorkflowGraphRunEdgeState>;onOpen?:(id:string)=>void;onDeleteNodes?:(ids:string[])=>void;onDeleteEdges?:(ids:string[])=>void;onTidy?:()=>void;readOnly?:boolean;}){
const mappedNodes=useMemo(()=>toNodes(graph,selectedId,nodeStates),[graph,nodeStates,selectedId]),mappedEdges=useMemo(()=>toEdges(graph,nodeStates,edgeStates),[edgeStates,graph,nodeStates]);
- const compactFitNodeIds=useMemo(()=>{if(readOnly)return graph.nodes.slice(0,2).map((node)=>node.id);const triggers=graph.nodes.filter((node)=>["manual","schedule","webhook"].includes(node.type)).map((node)=>node.id);return (triggers.length?triggers:[graph.nodes[0]?.id]).filter((id):id is string=>Boolean(id)).slice(0,2);},[graph.nodes,readOnly]);
+ const compactFitNodeIds=useMemo(()=>{if(readOnly)return graph.nodes.slice(0,9).map((node)=>node.id);const triggers=graph.nodes.filter((node)=>["manual","schedule","webhook"].includes(node.type)).map((node)=>node.id);return (triggers.length?triggers:[graph.nodes[0]?.id]).filter((id):id is string=>Boolean(id)).slice(0,2);},[graph.nodes,readOnly]);
const[nodes,setNodes,onNodesChange]=useNodesState<FlowNode>(mappedNodes),[edges,setEdges,onEdgesChange]=useEdgesState<FlowEdge>(mappedEdges);useEffect(()=>setNodes(mappedNodes),[mappedNodes,setNodes]);useEffect(()=>setEdges(mappedEdges),[mappedEdges,setEdges]);
const connect=(connection:Connection)=>{if(!connection.source||!connection.target||connection.source===connection.target)return;const handle=connection.sourceHandle&&connection.sourceHandle!=="output"?connection.sourceHandle:undefined;onConnect(connection.source,connection.target,handle);};
return <GraphCanvas<FlowNode,FlowEdge> ariaLabel="Workflow canvas" nodes={nodes} edges={edges} nodeTypes={nodeTypes} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={readOnly?undefined:connect} onPaneClick={()=>onSelect(null)} onNodeClick={(_,item)=>onSelect(item.id)} onNodeDoubleClick={(_,item)=>{const node=item.data.node;if((readOnly||node.type==="project"||node.type==="folder")&&onOpen)onOpen(node.id);}} onNodeDragStop={(_,item)=>onMove(item.id,item.position)} onNodesDelete={readOnly?undefined:(items)=>onDeleteNodes?.(items.map((item)=>item.id))} onEdgesDelete={readOnly?undefined:(items)=>onDeleteEdges?.(items.map((item)=>item.id))} isValidConnection={(connection)=>Boolean(connection.source&&connection.target&&connection.source!==connection.target&&!graph.edges.some((edge)=>edge.source===connection.source&&edge.target===connection.target&&(edge.sourceHandle??undefined)===(connection.sourceHandle==="output"?undefined:connection.sourceHandle??undefined)))} nodesDraggable={!readOnly} nodesConnectable={!readOnly} edgesReconnectable={false} deleteKeyCode={readOnly?null:["Backspace","Delete"]} onTidy={onTidy} snapToGrid snapGrid={[12,12]} defaultEdgeOptions={{type:"smoothstep",markerEnd:{type:MarkerType.ArrowClosed}}} miniMapNodeColor={(node)=>minimapColor(node as FlowNode)} miniMapNodeStrokeColor={(node)=>node.selected?"var(--accent)":"var(--border)"} compactFitNodeIds={compactFitNodeIds} compactFitMaxZoom={readOnly?0.72:0.9}/>
diff --git a/frontend/slices/workflows/components/workflow-session-details.tsx b/frontend/slices/workflows/components/workflow-session-details.tsx
index 3bccf642..de71dfb1 100644
--- a/frontend/slices/workflows/components/workflow-session-details.tsx
+++ b/frontend/slices/workflows/components/workflow-session-details.tsx
@@ -1,36 +1,50 @@
"use client";
-import { ExternalLink, TerminalSquare } from "lucide-react";
+import { Code2, Copy, ExternalLink, FileCode2, TerminalSquare } from "lucide-react";
+import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
-import type { SessionGraphView } from "@/lib/contracts/session-monitor";
+import type { SessionFlowAction, SessionFlowStep, SessionGraphView } from "@/lib/contracts/session-monitor";
import type { WorkflowGraphNode } from "@/lib/contracts/workflow-graph";
function value(config: Record<string, unknown>, key: string): string | undefined {
- const raw = config[key];
- return typeof raw === "string" && raw ? raw : undefined;
+ const raw = config[key]; return typeof raw === "string" && raw ? raw : undefined;
+}
+function actionReceipt(action: SessionFlowAction, onOpenTerminal: () => void, onOpenCode: (path: string) => void) {
+ return <details key={action.ref} className="group rounded-lg border bg-background/35">
+ <summary className="flex cursor-pointer list-none items-start gap-2 p-2.5 text-xs marker:hidden">
+ <code className="shrink-0 rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-semibold">{action.ref}</code>
+ <div className="min-w-0 flex-1"><div className="break-words font-medium leading-4">{action.title}</div><div className="mt-0.5 text-[10px] text-muted-foreground">{action.tool || action.kind}{action.state ? ` · ${action.state}` : ""}</div></div>
+ </summary>
+ <div className="space-y-2 border-t p-2.5">
+ {action.detail ? <div><div className="text-[10px] uppercase text-muted-foreground">Detail</div><p className="mt-1 whitespace-pre-wrap break-words text-[11px] [overflow-wrap:anywhere]">{action.detail}</p></div> : null}
+ {action.code ? <div className="overflow-hidden rounded-md border bg-muted/30"><div className="flex items-center gap-2 border-b px-2 py-1 text-[10px] text-muted-foreground"><Code2 className="size-3"/><span>{action.code.kind} · {action.code.language}</span><Button type="button" variant="ghost" size="icon" className="ml-auto size-6" aria-label={`Copy ${action.ref} code`} onClick={() => void navigator.clipboard?.writeText(action.code!.content)}><Copy className="size-3"/></Button></div><pre className="max-h-56 overflow-auto whitespace-pre p-2.5 font-mono text-[10px] leading-4"><code>{action.code.content}</code></pre></div> : null}
+ <div className="flex flex-wrap gap-1.5">
+ {action.terminalContext ? <Button type="button" size="sm" variant="outline" className="h-7 text-[10px]" onClick={onOpenTerminal}><TerminalSquare className="size-3.5"/>Open terminal here<ExternalLink className="size-3"/></Button> : null}
+ {action.artifact ? <Button type="button" size="sm" variant="outline" className="h-7 text-[10px]" onClick={() => onOpenCode(action.artifact!.path)}><FileCode2 className="size-3.5"/>Open {action.artifact.label} in Code<ExternalLink className="size-3"/></Button> : null}
+ </div>
+ <div className="flex flex-wrap gap-x-3 gap-y-1 text-[9px] text-muted-foreground"><span>{new Date(action.at).toLocaleString()}</span><span>{action.eventRef}</span>{action.artifact ? <span className="break-all">{action.artifact.path}</span> : null}</div>
+ </div>
+ </details>;
}
-export function WorkflowSessionDetails({ view, node, onOpenTerminal }: { view: SessionGraphView; node: WorkflowGraphNode | null; onOpenTerminal: () => void }) {
- const config = node?.config ?? {};
- const terminalContext = config.terminalContext === true;
+export function WorkflowSessionDetails({ view, node, onOpenTerminal, onOpenCode }: { view: SessionGraphView; node: WorkflowGraphNode | null; onOpenTerminal: () => void; onOpenCode: (path: string) => void }) {
+ const ref = node ? value(node.config, "ref") : undefined;
+ const step: SessionFlowStep | undefined = ref ? view.steps.find((item) => item.ref === ref) : undefined;
return <div className="flex h-full min-h-0 flex-col bg-card/20">
<div className="border-b p-3">
- <div className="truncate text-sm font-semibold">{view.session.label}</div>
- <div className="mt-1 text-[10px] uppercase text-muted-foreground">{view.session.source} · {view.session.status}</div>
- <p className="mt-2 text-xs text-muted-foreground">Read-only session projection. Tool payloads and raw transcripts are not duplicated into the graph.</p>
- {view.omittedEvents ? <p className="mt-2 text-[10px] text-muted-foreground">Showing the latest {view.shownEvents} of {view.totalEvents} events for canvas performance.</p> : null}
+ <div className="break-words text-sm font-semibold">{view.session.label}</div>
+ <div className="mt-1 flex flex-wrap items-center gap-1.5 text-[10px] uppercase text-muted-foreground"><span>{view.session.source}</span><span>·</span><span>{view.session.status}</span><Badge variant="outline" className="h-5 px-1.5 text-[9px] normal-case">{view.steps.length} semantic steps</Badge></div>
+ <p className="mt-2 text-xs text-muted-foreground">Canvas shows intent-level steps. Click a step to inspect its grouped actions, commands, code, artifacts, and raw execution receipt.</p>
+ {view.omittedEvents ? <p className="mt-2 text-[10px] text-muted-foreground">Projection uses the latest {view.shownEvents} of {view.totalEvents} events to stay fast. Raw session history remains the source of truth.</p> : null}
</div>
<ScrollArea className="min-h-0 flex-1"><div className="space-y-3 p-3">
- {!node ? <p className="text-xs text-muted-foreground">Select a node to inspect its recorded activity.</p> : <>
- <div><div className="text-[10px] uppercase text-muted-foreground">Node</div><div className="break-words text-sm font-semibold">{node.name}</div></div>
- {value(config, "state") ? <div><div className="text-[10px] uppercase text-muted-foreground">State</div><div className="text-xs">{value(config, "state")}</div></div> : null}
- {value(config, "at") ? <div><div className="text-[10px] uppercase text-muted-foreground">Time</div><time className="text-xs" dateTime={value(config, "at")}>{new Date(value(config, "at")!).toLocaleString()}</time></div> : null}
- {value(config, "detail") ? <div><div className="text-[10px] uppercase text-muted-foreground">Detail</div><p className="whitespace-pre-wrap break-words text-xs [overflow-wrap:anywhere]">{value(config, "detail")}</p></div> : null}
- {view.session.cwd ? <div><div className="text-[10px] uppercase text-muted-foreground">Context</div><p className="break-all text-xs text-muted-foreground">{view.session.cwd}</p></div> : null}
- {terminalContext ? <Button className="w-full" variant="outline" onClick={onOpenTerminal}><TerminalSquare className="size-4"/>Open terminal here<ExternalLink className="ml-auto size-3.5"/></Button> : null}
- </>}
+ {!node || node.id === "session-root" ? <><div><div className="text-[10px] uppercase text-muted-foreground">Flow</div><div className="mt-1 text-sm font-semibold">{view.session.title}</div></div><div className="space-y-1.5">{view.steps.map((item) => <div key={item.ref} className="rounded-lg border bg-background/35 p-2"><div className="flex items-center gap-2"><code className="rounded bg-muted px-1.5 py-0.5 text-[10px] font-semibold">{item.ref}</code><span className="text-xs font-medium">{item.title}</span><span className="ml-auto text-[10px] text-muted-foreground">{item.actions.length} actions</span></div><p className="mt-1 text-[10px] text-muted-foreground">{item.summary}</p></div>)}</div></> : step ? <>
+ <div><div className="flex items-center gap-2"><code className="rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] font-semibold">{step.ref}</code><Badge variant="outline" className="text-[9px] capitalize">{step.category}</Badge></div><div className="mt-2 break-words text-sm font-semibold">{step.title}</div><p className="mt-1 text-xs text-muted-foreground">{step.summary}</p></div>
+ <div className="border-t pt-3"><div className="mb-2 flex items-center justify-between"><div className="text-[10px] font-semibold uppercase text-muted-foreground">Actions</div><span className="text-[10px] text-muted-foreground">{step.actions.length}</span></div><div className="space-y-1.5">{step.actions.map((action) => actionReceipt(action, onOpenTerminal, onOpenCode))}</div></div>
+ </> : <p className="text-xs text-muted-foreground">Select a semantic step to inspect its actions.</p>}
+ {view.session.cwd ? <div className="border-t pt-3"><div className="text-[10px] uppercase text-muted-foreground">Session context</div><p className="mt-1 break-all font-mono text-[10px] text-muted-foreground">{view.session.cwd}</p></div> : null}
</div></ScrollArea>
- <div className="border-t p-3 text-[10px] text-muted-foreground">Successful MCP/Alfa workflows continue through MSO&apos;s existing learned-from-session automation pipeline; this view does not duplicate that state.</div>
+ <div className="border-t p-3 text-[10px] text-muted-foreground">Use references such as <code>S3.A4</code> when discussing a specific action. MSO keeps internal session IDs hidden from this surface.</div>
</div>;
}
diff --git a/frontend/slices/workflows/components/workflow-session-library.tsx b/frontend/slices/workflows/components/workflow-session-library.tsx
index 4f23b891..51814e50 100644
--- a/frontend/slices/workflows/components/workflow-session-library.tsx
+++ b/frontend/slices/workflows/components/workflow-session-library.tsx
@@ -16,25 +16,25 @@ export function WorkflowSessionLibrary({ activeId, onSelect }: { activeId?: stri
void listWorkflowSessions(page, query).then((value) => { if (alive) { setError(""); setData(value); } }).catch((cause) => { if (alive) setError(cause instanceof Error ? cause.message : "Sessions unavailable"); });
return () => { alive = false; };
}, [page, query, nonce]);
- return <div className="flex h-full min-h-0 flex-col bg-card/20">
- <div className="space-y-2 border-b p-2">
- <form className="flex gap-1" onSubmit={(event) => { event.preventDefault(); setPage(1); setQuery(search.trim()); }}>
- <div className="relative min-w-0 flex-1"><Search className="absolute left-2 top-2.5 size-3 text-muted-foreground"/><Input className="h-8 pl-7" aria-label="Search sessions" placeholder="agent-context" value={search} onChange={(event) => { setSearch(event.target.value); if (!event.target.value) { setPage(1); setQuery(""); } }}/></div>
- <Button type="submit" variant="outline" size="icon" className="size-8" aria-label="Search sessions"><Search className="size-3.5"/></Button>
- <Button type="button" variant="ghost" size="icon" className="size-8" aria-label="Refresh sessions" onClick={() => setNonce((value) => value + 1)}><RefreshCw className="size-3.5"/></Button>
+ return <div className="flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-card/20">
+ <div className="shrink-0 space-y-2 border-b p-3">
+ <form className="flex min-w-0 gap-1" onSubmit={(event) => { event.preventDefault(); setPage(1); setQuery(search.trim()); }}>
+ <div className="relative min-w-0 flex-1"><Search className="absolute left-2 top-2.5 size-3 text-muted-foreground"/><Input className="h-8 min-w-0 pl-7" aria-label="Search sessions" placeholder="Search agent, context, project…" value={search} onChange={(event) => { setSearch(event.target.value); if (!event.target.value) { setPage(1); setQuery(""); } }}/></div>
+ <Button type="submit" variant="outline" size="icon" className="size-8 shrink-0" aria-label="Search sessions"><Search className="size-3.5"/></Button>
+ <Button type="button" variant="ghost" size="icon" className="size-8 shrink-0" aria-label="Refresh sessions" onClick={() => setNonce((value) => value + 1)}><RefreshCw className="size-3.5"/></Button>
</form>
- <p className="text-[10px] text-muted-foreground">Read-only execution history. Labels use agent-context, while internal IDs stay hidden.</p>
+ <p className="text-[10px] leading-4 text-muted-foreground">Readable execution flows. Session labels use agent-context; internal IDs stay hidden.</p>
</div>
- <ScrollArea className="min-h-0 flex-1"><div className="space-y-1 p-2">
+ <ScrollArea className="min-h-0 min-w-0 flex-1"><div className="space-y-1.5 p-2.5">
{error ? <p className="p-2 text-xs text-destructive">{error}</p> : null}
{!data && !error ? <p className="p-3 text-xs text-muted-foreground">Loading sessions…</p> : null}
- {data?.sessions.map((session) => <button key={session.id} type="button" onClick={() => onSelect(session.id)} aria-pressed={activeId === session.id} className={`w-full rounded-lg border p-2 text-left text-xs transition-colors hover:bg-accent/60 ${activeId === session.id ? "bg-accent" : "bg-card"}`}>
- <div className="flex items-center gap-2"><Activity className="size-3.5 shrink-0 text-muted-foreground"/><div className="min-w-0 flex-1 truncate font-medium">{session.label}</div><span className="shrink-0 text-[9px] uppercase text-muted-foreground">{session.status}</span></div>
- <p className="mt-1 line-clamp-2 break-words text-[10px] text-muted-foreground">{session.title}</p>
- <p className="mt-1 text-[10px] text-muted-foreground">{session.source} · {session.eventCount} events</p>
+ {data?.sessions.map((session) => <button key={session.id} type="button" onClick={() => onSelect(session.id)} aria-pressed={activeId === session.id} title={session.label} className={`w-full min-w-0 rounded-lg border p-2.5 text-left text-xs transition-colors hover:bg-accent/60 ${activeId === session.id ? "bg-accent ring-1 ring-ring/30" : "bg-card"}`}>
+ <div className="flex min-w-0 items-start gap-2"><Activity className="mt-0.5 size-3.5 shrink-0 text-muted-foreground"/><div className="min-w-0 flex-1 break-words font-medium leading-4 [overflow-wrap:anywhere]">{session.label}</div><span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground">{session.status}</span></div>
+ <p className="mt-1.5 line-clamp-3 break-words pl-5.5 text-[10px] leading-4 text-muted-foreground [overflow-wrap:anywhere]">{session.title}</p>
+ <p className="mt-1 pl-5.5 text-[10px] text-muted-foreground">{session.source} · {session.eventCount} events</p>
</button>)}
{data && data.sessions.length === 0 && !error ? <p className="p-3 text-xs text-muted-foreground">No matching sessions.</p> : null}
</div></ScrollArea>
- {data && data.pages > 1 ? <div className="flex items-center justify-between border-t p-2 text-[10px] text-muted-foreground"><Button size="icon" variant="ghost" className="size-7" disabled={data.page <= 1} onClick={() => setPage((value) => Math.max(1, value - 1))}><ChevronLeft className="size-3.5"/></Button><span>{data.page} / {data.pages}</span><Button size="icon" variant="ghost" className="size-7" disabled={data.page >= data.pages} onClick={() => setPage((value) => Math.min(data.pages, value + 1))}><ChevronRight className="size-3.5"/></Button></div> : null}
+ {data && data.pages > 1 ? <div className="flex shrink-0 items-center justify-between border-t px-2 py-1.5 text-[10px] text-muted-foreground"><Button size="icon" variant="ghost" className="size-7" disabled={data.page <= 1} onClick={() => setPage((value) => Math.max(1, value - 1))}><ChevronLeft className="size-3.5"/></Button><span className="truncate px-2">Page {data.page} of {data.pages} · {data.total} sessions</span><Button size="icon" variant="ghost" className="size-7" disabled={data.page >= data.pages} onClick={() => setPage((value) => Math.min(data.pages, value + 1))}><ChevronRight className="size-3.5"/></Button></div> : null}
</div>;
}
diff --git a/frontend/slices/workflows/session-graph-ui.test.ts b/frontend/slices/workflows/session-graph-ui.test.ts
index b858f022..ede86432 100644
--- a/frontend/slices/workflows/session-graph-ui.test.ts
+++ b/frontend/slices/workflows/session-graph-ui.test.ts
@@ -6,6 +6,8 @@ const settingsSessions = readFileSync(new URL("../os-settings/components/mcp-ses
const settingsDetail = readFileSync(new URL("../os-settings/components/mcp-session-detail.tsx", import.meta.url), "utf8");
const sessionGuide = readFileSync(new URL("../os-settings/components/mcp-session-guide.tsx", import.meta.url), "utf8");
const inspector = readFileSync(new URL("./components/workflow-inspector.tsx", import.meta.url), "utf8");
+const sessionDetails = readFileSync(new URL("./components/workflow-session-details.tsx", import.meta.url), "utf8");
+const sessionLibrary = readFileSync(new URL("./components/workflow-session-library.tsx", import.meta.url), "utf8");
describe("Workflow session graph UI contract", () => {
it("routes Settings sessions into the Workflow Sessions view and never renders the internal id", () => {
@@ -17,9 +19,18 @@ describe("Workflow session graph UI contract", () => {
}
});
- it("keeps session graphs read-only and opens terminal context in a fresh window", () => {
+ it("keeps session graphs read-only and makes tool execution an explicit inspector action", () => {
expect(workflowApp).toContain('type LibraryMode = "automations" | "sessions"');
expect(workflowApp).toContain("readOnly/>");
- expect(workflowApp).toContain('openWindow("os-terminal", "Terminal", undefined, { initialCwd: sessionView.session.cwd || "~" }, { multi: true })');
+ expect(workflowApp).toContain('const chooseSessionNode = (id: string | null) => { setSessionSelected(id); if (id && overlayPane) setDetailsOpen(true); };');
+ expect(sessionDetails).toContain("Open terminal here");
+ expect(sessionDetails).toContain("Open {action.artifact.label} in Code");
+ expect(sessionDetails).toContain("S3.A4");
+ });
+
+ it("gives the desktop session library enough width and lets labels wrap instead of clipping", () => {
+ expect(workflowApp).toContain("grid-cols-[300px_minmax(0,1fr)]");
+ expect(sessionLibrary).toContain("[overflow-wrap:anywhere]");
+ expect(sessionLibrary).toContain("Page {data.page} of {data.pages}");
});
});
diff --git a/lib/agent/session-flow.test.ts b/lib/agent/session-flow.test.ts
new file mode 100644
index 00000000..490875c1
--- /dev/null
+++ b/lib/agent/session-flow.test.ts
@@ -0,0 +1,35 @@
+import { describe, expect, it } from "vitest";
+import { semanticSessionFlow } from "./session-flow";
+import type { AgentSessionEvent } from "./session-types";
+
+const at = (n: number) => new Date(1_780_000_000_000 + n * 1000).toISOString();
+
+describe("semantic session flow", () => {
+ it("compresses raw tool events into readable steps with referable actions", () => {
+ const events: AgentSessionEvent[] = [
+ { at: at(0), kind: "created", detail: "session started" },
+ { at: at(1), kind: "tool", tool: "exec_run", state: "completed", detail: "git status --short" },
+ { at: at(2), kind: "tool", tool: "fs_read", state: "completed", detail: "frontend/app.tsx" },
+ { at: at(3), kind: "tool", tool: "fs_write", state: "completed", detail: "scripts/release.sh" },
+ { at: at(4), kind: "tool", tool: "exec_run", state: "completed", detail: "bunx vitest run token=secret-value" },
+ { at: at(5), kind: "tool", tool: "exec_run", state: "completed", detail: "git commit -m release" },
+ { at: at(6), kind: "tool", tool: "exec_run", state: "completed", detail: "mso deploy" },
+ ];
+ const flow = semanticSessionFlow(events, 120, "/srv/project");
+ expect(flow.steps.length).toBeLessThanOrEqual(8);
+ expect(flow.steps.map((step) => step.category)).toEqual(expect.arrayContaining(["context", "inspect", "implement", "verify", "integrate", "deploy"]));
+ expect(flow.steps.flatMap((step) => step.actions).every((action) => /^S\d+\.A\d+$/.test(action.ref))).toBe(true);
+ expect(flow.steps.flatMap((step) => step.actions).map((action) => action.eventRef)).toEqual(["E1","E2","E3","E4","E5","E6","E7"]);
+ expect(JSON.stringify(flow)).not.toContain("secret-value");
+ });
+
+ it("exposes commands as code receipts and safe project-local file artifacts", () => {
+ const flow = semanticSessionFlow([
+ { at: at(0), kind: "tool", tool: "exec_run", state: "completed", detail: "bash scripts/release.sh" },
+ ], 120, "/srv/project");
+ const action = flow.steps[0]!.actions[0]!;
+ expect(action.code).toMatchObject({ kind: "command", language: "bash", content: "bash scripts/release.sh" });
+ expect(action.artifact).toMatchObject({ path: "/srv/project/scripts/release.sh", label: "release.sh", kind: "script" });
+ expect(action.terminalContext).toBe(true);
+ });
+});
diff --git a/lib/agent/session-flow.ts b/lib/agent/session-flow.ts
new file mode 100644
index 00000000..6ee6aa86
--- /dev/null
+++ b/lib/agent/session-flow.ts
@@ -0,0 +1,106 @@
+import path from "node:path";
+import { SESSION_GRAPH_EVENT_LIMIT, type SessionFlowAction, type SessionFlowCategory, type SessionFlowStep } from "@/lib/contracts/session-monitor";
+import { redactText } from "@/lib/security/redact-text";
+import type { AgentSessionEvent } from "./session-types";
+
+const STEP_LIMIT = 8;
+const CODE_EXTENSIONS = new Set(["ts","tsx","js","jsx","mjs","cjs","svelte","py","sh","bash","zsh","md","json","yaml","yml","css","scss","html","sql","toml"]);
+const TITLES: Record<SessionFlowCategory, string> = {
+ context: "Context", plan: "Plan", inspect: "Inspect", implement: "Implement",
+ verify: "Verify", integrate: "Integrate", deploy: "Deploy", result: "Result", other: "Actions",
+};
+
+function text(value: string | undefined, max = 1000): string | undefined {
+ return value ? redactText(value, max).replace(/[\u0000-\u001f\u007f]/g, " ").trim() || undefined : undefined;
+}
+function safeEvent(row: AgentSessionEvent) {
+ return { at: row.at, kind: text(row.kind, 40) || "note", tool: text(row.tool, 100), state: text(row.state, 60), detail: text(row.detail, 1000) };
+}
+function classify(event: ReturnType<typeof safeEvent>): SessionFlowCategory {
+ const tool = (event.tool || "").toLowerCase(), detail = (event.detail || "").toLowerCase(), hay = `${tool} ${detail}`;
+ if (["created", "resumed", "compacted"].includes(event.kind)) return "context";
+ if (event.kind === "archived" || /workflow_(finish|cancel)/.test(tool)) return "result";
+ if (/workflow_start/.test(tool) || /\b(plan|intent|scope|approach)\b/.test(detail) && event.kind === "note") return "plan";
+ if (/\b(deploy|dokploy|systemctl|restart|health(?:check)?|production|cloudflare)\b/.test(hay)) return "deploy";
+ if (/\bgit\s+(add|commit|merge|cherry-pick|push|rebase|reset|tag)\b/.test(detail) || /\b(pull request|\bpr\b)\b/.test(hay)) return "integrate";
+ if (/\b(test|vitest|playwright|lint|typecheck|coverage|audit|verify|verification|check|build)\b/.test(hay)) return "verify";
+ if (/\b(fs_write|fs_delete|fs_move|fs_copy|apply_patch|patch|edit|update|create|save|write)\b/.test(tool) || /\b(sed\s+-i|perl\s+-pi|mkdir|rm\s+-|cp\s+|mv\s+|cat\s+>|tee\s+)\b/.test(detail)) return "implement";
+ if (/\b(fs_read|fs_list|fs_search|read|search|list|query|inspect|status|find)\b/.test(tool) || /^(git\s+(status|diff|log|show)|rg\b|grep\b|find\b|ls\b|cat\b|sed\s+-n)/.test(detail)) return "inspect";
+ if (event.kind === "note") return "context";
+ if (event.kind === "workflow") return "plan";
+ return "other";
+}
+function humanize(value: string): string {
+ return value.replace(/[_.:-]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase()).trim();
+}
+function actionTitle(event: ReturnType<typeof safeEvent>): string {
+ const detail = event.detail?.split("\n")[0]?.trim();
+ if (event.tool && /^(exec(?:_|\.)|terminal|shell)/i.test(event.tool) && detail) return `Run · ${detail}`.slice(0, 110);
+ if (event.tool && /^fs_(read|write|delete|move|copy)/i.test(event.tool) && detail) return `${humanize(event.tool)} · ${detail}`.slice(0, 110);
+ return humanize(event.tool || event.kind || "Action").slice(0, 110);
+}
+function languageFor(filePath: string): string {
+ const ext = filePath.split(".").pop()?.toLowerCase() || "";
+ return ({ ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",mjs:"javascript",cjs:"javascript",svelte:"svelte",py:"python",sh:"bash",bash:"bash",zsh:"zsh",md:"markdown",json:"json",yaml:"yaml",yml:"yaml",css:"css",scss:"scss",html:"html",sql:"sql",toml:"toml" } as Record<string,string>)[ext] || "text";
+}
+function artifactPath(detail: string | undefined, cwd: string | undefined): SessionFlowAction["artifact"] | undefined {
+ if (!detail || !cwd) return undefined;
+ const candidates = detail.match(/(?:\.?\.?\/)?[[email protected]]+(?:\/[[email protected]]+)*\.[A-Za-z0-9]+/g) || [];
+ for (const raw of candidates) {
+ const ext = raw.split(".").pop()?.toLowerCase() || "";
+ if (!CODE_EXTENSIONS.has(ext) || raw.includes("..")) continue;
+ const resolved = path.isAbsolute(raw) ? path.resolve(raw) : path.resolve(cwd, raw.replace(/^\.\//, ""));
+ const rel = path.relative(path.resolve(cwd), resolved);
+ if (rel === ".." || rel.startsWith(`..${path.sep}`) || path.isAbsolute(rel)) continue;
+ return { path: resolved, label: path.basename(resolved), kind: ["sh","bash","zsh","py","js","ts"].includes(ext) ? "script" : "file", language: languageFor(resolved) };
+ }
+ return undefined;
+}
+function actionCode(event: ReturnType<typeof safeEvent>, artifact: SessionFlowAction["artifact"]): SessionFlowAction["code"] | undefined {
+ if (!event.detail) return undefined;
+ if (event.tool && /^(exec(?:_|\.)|terminal|shell|project_script_run)/i.test(event.tool)) return { kind: /script/i.test(event.tool) ? "script" : "command", language: "bash", content: event.detail };
+ if (artifact && event.detail.includes("\n")) return { kind: artifact.kind === "script" ? "script" : "snippet", language: artifact.language || "text", content: event.detail };
+ return undefined;
+}
+function dominantCategory(actions: SessionFlowAction[]): SessionFlowCategory {
+ const counts = new Map<SessionFlowCategory, number>();
+ for (const action of actions) counts.set(action.category, (counts.get(action.category) || 0) + 1);
+ return [...counts.entries()].sort((a,b) => b[1] - a[1])[0]?.[0] || "other";
+}
+function summarize(actions: SessionFlowAction[]): string {
+ const tools = [...new Set(actions.map((action) => action.tool).filter((tool): tool is string => Boolean(tool)))].slice(0, 3).map(humanize);
+ return `${actions.length} action${actions.length === 1 ? "" : "s"}${tools.length ? ` · ${tools.join(" · ")}` : ""}`;
+}
+
+export function semanticSessionFlow(events: AgentSessionEvent[], requestedLimit = SESSION_GRAPH_EVENT_LIMIT, cwd?: string) {
+ const limit = Math.max(1, Math.min(SESSION_GRAPH_EVENT_LIMIT, Math.trunc(requestedLimit) || SESSION_GRAPH_EVENT_LIMIT));
+ const totalEvents = events.length, omittedEvents = Math.max(0, totalEvents - limit);
+ const actions = events.slice(-limit).map(safeEvent).map((event, index): SessionFlowAction => {
+ const artifact = artifactPath(event.detail, cwd), category = classify(event);
+ return { ref: "", eventRef: `E${omittedEvents + index + 1}`, title: actionTitle(event), category, at: event.at, kind: event.kind,
+ ...(event.tool ? { tool: event.tool } : {}), ...(event.state ? { state: event.state } : {}), ...(event.detail ? { detail: event.detail } : {}),
+ terminalContext: Boolean(event.tool && /^(exec(?:_|\.)|terminal|shell)/i.test(event.tool)), ...(artifact ? { artifact } : {}),
+ ...(actionCode(event, artifact) ? { code: actionCode(event, artifact) } : {}),
+ };
+ });
+ let groups: SessionFlowAction[][] = [];
+ for (const action of actions) {
+ const last = groups.at(-1);
+ if (last && last.at(-1)?.category === action.category) last.push(action); else groups.push([action]);
+ }
+ while (groups.length > STEP_LIMIT) {
+ let smallest = 0;
+ for (let i = 1; i < groups.length; i += 1) if (groups[i]!.length < groups[smallest]!.length) smallest = i;
+ const target = smallest === 0 ? 1 : smallest === groups.length - 1 ? smallest - 1 : groups[smallest - 1]!.length <= groups[smallest + 1]!.length ? smallest - 1 : smallest + 1;
+ const start = Math.min(smallest, target), merged = [...groups[start]!, ...groups[start + 1]!];
+ groups.splice(start, 2, merged);
+ }
+ const steps: SessionFlowStep[] = groups.map((group, stepIndex) => {
+ const ref = `S${stepIndex + 1}`, category = dominantCategory(group);
+ const categories = [...new Set(group.map((action) => action.category))];
+ group.forEach((action, actionIndex) => { action.ref = `${ref}.A${actionIndex + 1}`; });
+ return { ref, title: categories.length === 1 ? TITLES[category] : categories.slice(0, 2).map((item) => TITLES[item]).join(" & "), category,
+ summary: summarize(group), startedAt: group[0]!.at, finishedAt: group.at(-1)!.at, actions: group };
+ });
+ return { totalEvents, shownEvents: actions.length, omittedEvents, steps };
+}
diff --git a/lib/agent/session-graph.ts b/lib/agent/session-graph.ts
index 263033e4..79f37e1e 100644
--- a/lib/agent/session-graph.ts
+++ b/lib/agent/session-graph.ts
@@ -1,112 +1,26 @@
import { SESSION_GRAPH_EVENT_LIMIT } from "@/lib/contracts/session-monitor";
import type { SessionCard, SessionGraphView } from "@/lib/contracts/session-monitor";
import type { WorkflowGraph, WorkflowGraphNode } from "@/lib/contracts/workflow-graph";
-import { redactText } from "@/lib/security/redact-text";
-import type { AgentSession, AgentSessionEvent } from "./session-types";
+import type { AgentSession } from "./session-types";
+import { semanticSessionFlow } from "./session-flow";
-function text(value: string | undefined, max = 500): string | undefined {
- return value ? redactText(value, max).replace(/[\u0000-\u001f\u007f]/g, " ") : undefined;
-}
-
-function safeEvent(row: AgentSessionEvent) {
- return {
- at: row.at,
- kind: text(row.kind, 40) || "note",
- tool: text(row.tool, 100),
- state: text(row.state, 60),
- detail: text(row.detail, 1000),
- workflowId: text(row.workflowId, 100),
- };
-}
-
-function nodeName(event: ReturnType<typeof safeEvent>): string {
- return (event.tool || event.kind || "event")
- .replace(/[_.:-]+/g, " ")
- .replace(/\b\w/g, (char) => char.toUpperCase())
- .slice(0, 120);
-}
-
-function nodeType(event: ReturnType<typeof safeEvent>): WorkflowGraphNode["type"] {
- if (event.kind === "workflow") return "subflow";
- if (["note", "compacted", "archived"].includes(event.kind)) return "memory";
- return "tool";
-}
-
-export function sessionGraph(
- record: AgentSession,
- session: SessionCard,
- requestedLimit = SESSION_GRAPH_EVENT_LIMIT,
-): SessionGraphView {
- const limit = Math.max(
- 1,
- Math.min(SESSION_GRAPH_EVENT_LIMIT, Math.trunc(requestedLimit) || SESSION_GRAPH_EVENT_LIMIT),
- );
- const totalEvents = record.events.length;
- const omittedEvents = Math.max(0, totalEvents - limit);
- const events = record.events.slice(-limit).map(safeEvent);
+export function sessionGraph(record: AgentSession, session: SessionCard, requestedLimit = SESSION_GRAPH_EVENT_LIMIT): SessionGraphView {
+ const flow = semanticSessionFlow(record.events, requestedLimit, session.cwd);
const root: WorkflowGraphNode = {
- id: "session-root",
- name: session.label,
- type: "session",
- position: { x: 70, y: 100 },
- config: {
- label: session.label,
- source: session.source,
- status: session.status,
- title: session.title,
- ...(session.cwd ? { cwd: session.cwd } : {}),
- },
+ id: "session-root", name: session.label, type: "session", position: { x: 60, y: 90 },
+ config: { sessionRoot: true, label: session.label, source: session.source, status: session.status, title: session.title, ...(session.cwd ? { cwd: session.cwd } : {}), stepCount: flow.steps.length },
};
- const eventNodes: WorkflowGraphNode[] = events.map((event, index) => {
- const row = Math.floor(index / 4);
- const column = index % 4;
- const displayColumn = row % 2 === 0 ? column : 3 - column;
- return {
- id: `event-${omittedEvents + index + 1}`,
- name: nodeName(event),
- type: nodeType(event),
- position: { x: 340 + displayColumn * 250, y: 70 + row * 140 },
- config: {
- at: event.at,
- kind: event.kind,
- ...(event.tool ? { tool: event.tool } : {}),
- ...(event.state ? { state: event.state } : {}),
- ...(event.detail ? { detail: event.detail } : {}),
- terminalContext: Boolean(event.tool && /^(exec(?:_|\.)|terminal|shell)/i.test(event.tool)),
- },
- };
+ const stepNodes: WorkflowGraphNode[] = flow.steps.map((step, index) => {
+ const slot = index + 1, row = Math.floor(slot / 3), column = slot % 3, displayColumn = row % 2 === 0 ? column : 2 - column;
+ return { id: `step-${index + 1}`, name: `${step.ref} · ${step.title}`, type: "subflow", position: { x: 60 + displayColumn * 310, y: 90 + row * 180 },
+ config: { sessionStep: true, ref: step.ref, category: step.category, summary: step.summary, actionCount: step.actions.length, startedAt: step.startedAt, finishedAt: step.finishedAt } };
});
- const nodes = [root, ...eventNodes];
- const edges = eventNodes.map((node, index) => ({
- id: `session-edge-${omittedEvents + index + 1}`,
- source: index === 0 ? root.id : eventNodes[index - 1]!.id,
- target: node.id,
- }));
+ const nodes = [root, ...stepNodes];
+ const edges = stepNodes.map((node, index) => ({ id: `session-step-edge-${index + 1}`, source: index === 0 ? root.id : stepNodes[index - 1]!.id, target: node.id }));
const graph: WorkflowGraph = {
- version: 2,
- id: `session:${record.id}`,
- name: session.label,
- description: session.title,
- status: "archived",
- inputs: {},
- nodes,
- edges,
- metadata: {
- provenance: "learned-from-session",
- intent: session.title,
- ...(session.cwd ? { project: session.cwd } : {}),
- tags: ["session", session.source],
- },
- createdAt: record.createdAt,
- updatedAt: record.updatedAt,
- revision: `session-${Date.parse(record.updatedAt) || 0}`,
- };
- return {
- session,
- graph,
- totalEvents,
- shownEvents: events.length,
- omittedEvents,
- observedAt: new Date().toISOString(),
+ version: 2, id: `session:${record.id}`, name: session.label, description: session.title, status: "archived", inputs: {}, nodes, edges,
+ metadata: { provenance: "learned-from-session", intent: session.title, ...(session.cwd ? { project: session.cwd } : {}), tags: ["session", "semantic-flow", session.source] },
+ createdAt: record.createdAt, updatedAt: record.updatedAt, revision: `session-${Date.parse(record.updatedAt) || 0}`,
};
+ return { session, graph, steps: flow.steps, totalEvents: flow.totalEvents, shownEvents: flow.shownEvents, omittedEvents: flow.omittedEvents, observedAt: new Date().toISOString() };
}
diff --git a/lib/agent/session-monitor.test.ts b/lib/agent/session-monitor.test.ts
index 8aa4d856..9ab136b9 100644
--- a/lib/agent/session-monitor.test.ts
+++ b/lib/agent/session-monitor.test.ts
@@ -71,7 +71,9 @@ describe("owner session monitor", () => {
expect(view?.graph.name).toBe("session-0-work-0");
expect(view?.graph.nodes[0]).toMatchObject({ id: "session-root", type: "session", name: "session-0-work-0" });
expect(view?.shownEvents).toBe(2); expect(view?.omittedEvents).toBe(1);
- expect(view?.graph.nodes.some((node) => node.config.terminalContext === true)).toBe(true);
+ expect(view?.graph.nodes.length).toBeLessThanOrEqual(1 + (view?.steps.length || 0));
+ expect(view?.steps.flatMap((step) => step.actions).some((action) => action.terminalContext === true)).toBe(true);
+ expect(view?.steps.flatMap((step) => step.actions).every((action) => /^S\d+\.A\d+$/.test(action.ref))).toBe(true);
expect(JSON.stringify(view)).not.toContain("secret-value");
});
diff --git a/lib/contracts/session-monitor.ts b/lib/contracts/session-monitor.ts
index b4e6baed..396b750c 100644
--- a/lib/contracts/session-monitor.ts
+++ b/lib/contracts/session-monitor.ts
@@ -46,9 +46,36 @@ export interface SessionDetail {
pageSize: number;
observedAt: string;
}
+
+export type SessionFlowCategory = "context" | "plan" | "inspect" | "implement" | "verify" | "integrate" | "deploy" | "result" | "other";
+export interface SessionFlowAction {
+ ref: string;
+ eventRef: string;
+ title: string;
+ category: SessionFlowCategory;
+ at: string;
+ kind: string;
+ tool?: string;
+ state?: string;
+ detail?: string;
+ terminalContext?: boolean;
+ code?: { kind: "command" | "script" | "snippet"; language: string; content: string };
+ artifact?: { path: string; label: string; kind: "file" | "script"; language?: string };
+}
+export interface SessionFlowStep {
+ ref: string;
+ title: string;
+ category: SessionFlowCategory;
+ summary: string;
+ startedAt: string;
+ finishedAt: string;
+ actions: SessionFlowAction[];
+}
+
export interface SessionGraphView {
session: SessionCard;
graph: WorkflowGraph;
+ steps: SessionFlowStep[];
totalEvents: number;
shownEvents: number;
omittedEvents: number;
diff --git a/lib/mcp/parity.test.ts b/lib/mcp/parity.test.ts
index e85477ad..7b03c888 100644
--- a/lib/mcp/parity.test.ts
+++ b/lib/mcp/parity.test.ts
@@ -55,6 +55,7 @@ const MCP_ONLY: Record<string, string> = {
"project.memory.upsert": "same repo-local RASMIC ledger; writes are workflow-scoped/audited for external agents rather than shared with Alfa owner recall",
"project.script.run": "RASMIC script replay is an external/terminal orchestration primitive that revalidates bounded read-only steps and may promote candidate metadata; Alfa has no matching workflow/script lifecycle",
"agent.session.current": "external MCP clients need a stable durable MSO session id they can quote from a later ChatGPT conversation; in-shell Alfa already owns its conversation identity",
+ "agent.session.flow": "semantic flow lookup reads the external durable AgentSession ledger used by MCP/terminal agents; Alfa browser threads intentionally keep a separate conversation identity, while the owner can inspect the same projection in the native Workflows Sessions UI",
"agent.sessions.list": "external MCP clients need explicit cross-conversation session discovery; Alfa's in-app thread UI already provides its own conversation list",
"agent.session.resume": "external MCP clients must reconstruct only the safe MSO resume packet across ChatGPT conversations; Alfa can reopen its own persisted in-app thread directly",
"agent.session.rename": "durable MCP/terminal session titles are metadata in the isolated agent-session store; Alfa keeps its separate in-app thread/title lifecycle",
diff --git a/lib/mcp/tool-contract.ts b/lib/mcp/tool-contract.ts
index b1172b6f..00de4e6d 100644
--- a/lib/mcp/tool-contract.ts
+++ b/lib/mcp/tool-contract.ts
@@ -46,7 +46,7 @@ const TITLES: Record<string, string> = {
project_mcp_tools: "List Project MCP Tools", project_mcp_call: "Call Project MCP Tool", project_function_call: "Call Project Function",
read_pipeline: "Run Read Pipeline", fs_list: "List Files", fs_read: "Read File", fs_search: "Search Directories", fs_write: "Write File",
exec_run: "Run Command", exec_job_start: "Start Command Job", exec_job_status: "Command Job Status", exec_job_cancel: "Cancel Command Job",
- agent_session_current: "Current Agent Session", agent_session_rename: "Rename Agent Session",
+ agent_session_current: "Current Agent Session", agent_session_flow: "Read Session Flow", agent_session_rename: "Rename Agent Session",
local_agents_list: "List Local Agents", local_agent_inbox: "Receive Local Agent Messages",
organization_chart: "Organization Chart", organization_manage: "Manage Organization",
local_agent_message_send: "Send Local Agent Message", local_agent_reply: "Reply to Local Agent", local_agent_request_wait: "Wait for Local Agent Reply",
@@ -110,7 +110,7 @@ function compactSchema(value: unknown): unknown {
for (const [key, item] of Object.entries(value as Record<string, unknown>)) {
if (key === "additionalProperties" && item === true || key === "required" && Array.isArray(item) && item.length === 0) continue;
if (key === "workflow_id" && item && typeof item === "object") out[key] = { type:"string" };
- else if (key === "description" && typeof item === "string") out[key] = compactText(item, 40);
+ else if (key === "description" && typeof item === "string") out[key] = compactText(item, 32);
else out[key] = compactSchema(item);
}
return out;
diff --git a/lib/mcp/tools-agent.ts b/lib/mcp/tools-agent.ts
index e6497695..fc8dd27c 100644
--- a/lib/mcp/tools-agent.ts
+++ b/lib/mcp/tools-agent.ts
@@ -3,6 +3,8 @@ import { forgetAgentMemory, queryAgentMemory, readAgentMemory, rememberAgentMemo
import { agentSessionSummary, appendAgentSessionEvent, getAgentSession, listAgentSessions, renameAgentSession, resumeAgentSession } from "@/lib/agent/session-store";
import { type McpTool, S, str } from "./tool-kit";
import { resolveAgentSessionRef } from "@/lib/agent/session-query";
+import { agentSessionLabel } from "@/lib/agent/session-name";
+import { semanticSessionFlow } from "@/lib/agent/session-flow";
function principal(context: { principal?: string }): string {
if (!context.principal) throw new Error("agent session principal is unavailable");
@@ -56,6 +58,30 @@ export const AGENT_TOOLS: McpTool[] = [
return resumeAgentSession(owner, target.id, context.sessionId);
},
},
+ {
+ name: "agent_session_flow",
+ description: "Read one session as a compact semantic flow for humans and agents. Returns intent-level steps with human-readable Sx.Ay action references, sanitized execution receipts, commands/code hints, and artifacts without exposing the internal session id. Pass action_ref to jump directly to one action.",
+ scope: "read", annotations: { readOnlyHint: true, idempotentHint: true },
+ inputSchema: S({
+ session_ref: { type: "string", description: "Human session label (agent-context), @name, title, or legacy exact id." },
+ action_ref: { type: "string", description: "Optional semantic action reference such as S3.A4 or event reference such as E217." },
+ limit: { type: "number", description: "Newest events to project, 1-120 (default 120)." },
+ }, ["session_ref"]),
+ run: async (a, context) => {
+ const owner = principal(context), target = await resolveAgentSessionRef(owner, str(a, "session_ref"));
+ const flow = semanticSessionFlow(target.events, Math.max(1, Math.min(120, Number(a.limit) || 120)), target.cwd);
+ const session = { label: agentSessionLabel(target.name, target.title, target.cwd), title: target.title, source: target.source, updatedAt: target.updatedAt, ...(target.cwd ? { cwd: target.cwd } : {}) };
+ const wanted = optionalString(a, "action_ref")?.toUpperCase();
+ if (wanted) {
+ for (const step of flow.steps) {
+ const action = step.actions.find((row) => row.ref.toUpperCase() === wanted || row.eventRef.toUpperCase() === wanted);
+ if (action) return { session, step: { ref: step.ref, title: step.title, category: step.category, summary: step.summary }, action };
+ }
+ throw new Error(`session action not found: ${wanted}`);
+ }
+ return { session, ...flow };
+ },
+ },
{
name: "agent_session_rename",
description: "Manually rename the current MSO session. Manual names are locked and will not be replaced by automatic workflow-based naming.",
diff --git a/scripts/e2e/mcp-sessions.mjs b/scripts/e2e/mcp-sessions.mjs
index f69e5fbd..17632056 100644
--- a/scripts/e2e/mcp-sessions.mjs
+++ b/scripts/e2e/mcp-sessions.mjs
@@ -61,12 +61,23 @@ export async function mcpSessionsJourney(page, fixture) {
await cards.first().click();
await expect(page.getByRole("application", { name: "Workflow canvas" })).toBeVisible();
await expect(page.getByText(openLabel, { exact: true }).last()).toBeVisible();
- const terminalToolNode = page.locator(".react-flow__node").filter({ hasText: "Exec Run" }).first();
+ const selectedMonitorResponse = await page.request.get(fixture.base + "/api/v1/agent-sessions?view=monitor&includeOffline=1&page=2");
+ const selectedMonitor = await selectedMonitorResponse.json();
+ const selectedGraphResponse = await page.request.get(fixture.base + `/api/v1/agent-sessions?view=graph&id=${encodeURIComponent(selectedMonitor.sessions[0].id)}`);
+ const selectedGraph = await selectedGraphResponse.json();
+ expect(selectedGraph.graph.nodes.length).toBeLessThanOrEqual(9);
+ const terminalStep = selectedGraph.steps.find(step => step.actions.some(action => action.terminalContext));
+ expect(terminalStep).toBeTruthy();
+ const terminalStepNode = page.locator(".react-flow__node").filter({ hasText: terminalStep.ref + " ·" }).first();
const terminalTabs = page.getByRole("tablist", { name: "Terminal sessions" });
const terminalCountBefore = await terminalTabs.count();
- await expect(terminalToolNode).toBeVisible();
+ await expect(terminalStepNode).toBeVisible();
expect(await page.locator('[data-slot="workflows-feature"]').innerText()).not.toMatch(/\b\d{8}_\d{6}_[a-f0-9]{8}\b/);
- await terminalToolNode.click();
+ await terminalStepNode.click();
+ await expect(page.getByText("Actions", { exact: true }).last()).toBeVisible();
+ await expect(page.getByRole("button", { name: /Open terminal here/ }).first()).toBeVisible();
+ expect(await terminalTabs.count()).toBe(terminalCountBefore); // Selecting a node must not launch tools.
+ await page.getByRole("button", { name: /Open terminal here/ }).first().click();
await expect(terminalTabs.last()).toBeVisible();
const backHome = page.getByRole("button", { name: "Back to Home", exact: true });
if (await backHome.isVisible().catch(() => false)) {
@@ -94,5 +105,5 @@ export async function mcpSessionsJourney(page, fixture) {
}
// Mobile/full-screen navigation changes the active route; restore Settings so the caller can continue its recovery journey.
await page.goto(fixture.base + "/settings");
- console.log("PASS session labels, Workflow graph handoff, terminal context, redaction, handover, keyboard and accessibility");
+ console.log("PASS session labels, semantic Workflow handoff, explicit terminal action, redaction, handover, keyboard and accessibility");
}