@@ -147,6 +147,8 @@ import {
147147 writeOpenworkServerSettings ,
148148 clearOpenworkServerSettings ,
149149 type OpenworkAuditEntry ,
150+ type OpenworkSoulHeartbeatEntry ,
151+ type OpenworkSoulStatus ,
150152 type OpenworkServerCapabilities ,
151153 type OpenworkServerDiagnostics ,
152154 type OpenworkServerStatus ,
@@ -1352,6 +1354,13 @@ export default function App() {
13521354 const [ scheduledJobsStatus , setScheduledJobsStatus ] = createSignal < string | null > ( null ) ;
13531355 const [ scheduledJobsBusy , setScheduledJobsBusy ] = createSignal ( false ) ;
13541356 const [ scheduledJobsUpdatedAt , setScheduledJobsUpdatedAt ] = createSignal < number | null > ( null ) ;
1357+ const [ soulStatusByWorkspaceId , setSoulStatusByWorkspaceId ] = createSignal <
1358+ Record < string , OpenworkSoulStatus | null >
1359+ > ( { } ) ;
1360+ const [ activeSoulHeartbeats , setActiveSoulHeartbeats ] = createSignal < OpenworkSoulHeartbeatEntry [ ] > ( [ ] ) ;
1361+ const [ soulStatusBusy , setSoulStatusBusy ] = createSignal ( false ) ;
1362+ const [ soulHeartbeatsBusy , setSoulHeartbeatsBusy ] = createSignal ( false ) ;
1363+ const [ soulError , setSoulError ] = createSignal < string | null > ( null ) ;
13551364
13561365 // MCP OAuth modal state
13571366 const [ mcpAuthModalOpen , setMcpAuthModalOpen ] = createSignal ( false ) ;
@@ -2571,6 +2580,163 @@ export default function App() {
25712580 return ;
25722581 } ;
25732582
2583+ const resolveSoulWorkspaceMap = async ( ) => {
2584+ const client = openworkServerClient ( ) ;
2585+ if ( ! client || openworkServerStatus ( ) !== "connected" ) {
2586+ return { } as Record < string , string > ;
2587+ }
2588+
2589+ const response = await client . listWorkspaces ( ) ;
2590+ const items = Array . isArray ( response . items ) ? response . items : [ ] ;
2591+ const map : Record < string , string > = { } ;
2592+
2593+ const idByLocalPath = new Map < string , string > ( ) ;
2594+ for ( const item of items ) {
2595+ const path = normalizeDirectoryPath ( item . path ?? "" ) ;
2596+ if ( ! path ) continue ;
2597+ idByLocalPath . set ( path , item . id ) ;
2598+ }
2599+
2600+ for ( const workspace of workspaceStore . workspaces ( ) ) {
2601+ if ( workspace . workspaceType === "local" ) {
2602+ const key = normalizeDirectoryPath ( workspace . path ?? "" ) ;
2603+ if ( ! key ) continue ;
2604+ const found = idByLocalPath . get ( key ) ;
2605+ if ( found ) {
2606+ map [ workspace . id ] = found ;
2607+ }
2608+ continue ;
2609+ }
2610+
2611+ if ( workspace . remoteType !== "openwork" ) {
2612+ continue ;
2613+ }
2614+
2615+ const explicitId =
2616+ workspace . openworkWorkspaceId ?. trim ( ) ||
2617+ parseOpenworkWorkspaceIdFromUrl ( workspace . openworkHostUrl ?? "" ) ||
2618+ parseOpenworkWorkspaceIdFromUrl ( workspace . baseUrl ?? "" ) ;
2619+ if ( explicitId ) {
2620+ map [ workspace . id ] = explicitId ;
2621+ continue ;
2622+ }
2623+
2624+ const directoryHint = normalizeDirectoryPath ( workspace . directory ?? workspace . path ?? "" ) ;
2625+ if ( ! directoryHint ) continue ;
2626+ const match = items . find ( ( entry ) => {
2627+ const entryPath = normalizeDirectoryPath (
2628+ ( entry . opencode ?. directory ?? entry . directory ?? entry . path ?? "" ) as string ,
2629+ ) ;
2630+ return Boolean ( entryPath && entryPath === directoryHint ) ;
2631+ } ) ;
2632+ if ( match ?. id ) {
2633+ map [ workspace . id ] = match . id ;
2634+ }
2635+ }
2636+
2637+ return map ;
2638+ } ;
2639+
2640+ const refreshSoulData = async ( options ?: { force ?: boolean } ) => {
2641+ if ( soulStatusBusy ( ) && ! options ?. force ) return ;
2642+
2643+ const client = openworkServerClient ( ) ;
2644+ if ( ! client || openworkServerStatus ( ) !== "connected" ) {
2645+ setSoulStatusByWorkspaceId ( { } ) ;
2646+ setActiveSoulHeartbeats ( [ ] ) ;
2647+ setSoulHeartbeatsBusy ( false ) ;
2648+ setSoulError ( null ) ;
2649+ return ;
2650+ }
2651+
2652+ setSoulStatusBusy ( true ) ;
2653+ setSoulError ( null ) ;
2654+ try {
2655+ const workspaceMap = await resolveSoulWorkspaceMap ( ) ;
2656+ const workspaceIds = Object . entries ( workspaceMap ) ;
2657+
2658+ const nextStatusByWorkspace : Record < string , OpenworkSoulStatus | null > = { } ;
2659+ for ( const workspace of workspaceStore . workspaces ( ) ) {
2660+ nextStatusByWorkspace [ workspace . id ] = null ;
2661+ }
2662+
2663+ let hadStatusError = false ;
2664+ await Promise . all (
2665+ workspaceIds . map ( async ( [ workspaceId , openworkId ] ) => {
2666+ try {
2667+ const status = await client . getSoulStatus ( openworkId ) ;
2668+ nextStatusByWorkspace [ workspaceId ] = status ;
2669+ } catch {
2670+ hadStatusError = true ;
2671+ nextStatusByWorkspace [ workspaceId ] = null ;
2672+ }
2673+ } ) ,
2674+ ) ;
2675+ setSoulStatusByWorkspaceId ( nextStatusByWorkspace ) ;
2676+
2677+ const activeWorkspaceId = workspaceStore . activeWorkspaceId ( ) ;
2678+ const activeOpenworkId = workspaceMap [ activeWorkspaceId ] ;
2679+ if ( ! activeOpenworkId ) {
2680+ setActiveSoulHeartbeats ( [ ] ) ;
2681+ setSoulHeartbeatsBusy ( false ) ;
2682+ if ( hadStatusError ) {
2683+ setSoulError ( "Soul status is partially unavailable." ) ;
2684+ }
2685+ return ;
2686+ }
2687+
2688+ setSoulHeartbeatsBusy ( true ) ;
2689+ try {
2690+ const response = await client . listSoulHeartbeats ( activeOpenworkId , 30 ) ;
2691+ setActiveSoulHeartbeats ( Array . isArray ( response . items ) ? response . items : [ ] ) ;
2692+ } catch ( error ) {
2693+ const message = error instanceof Error ? error . message : "Failed to load soul heartbeats." ;
2694+ setActiveSoulHeartbeats ( [ ] ) ;
2695+ setSoulError ( message ) ;
2696+ } finally {
2697+ setSoulHeartbeatsBusy ( false ) ;
2698+ }
2699+
2700+ if ( hadStatusError && ! soulError ( ) ) {
2701+ setSoulError ( "Soul status is partially unavailable." ) ;
2702+ }
2703+ } catch ( error ) {
2704+ const message = error instanceof Error ? error . message : "Failed to load soul status." ;
2705+ setSoulStatusByWorkspaceId ( { } ) ;
2706+ setActiveSoulHeartbeats ( [ ] ) ;
2707+ setSoulHeartbeatsBusy ( false ) ;
2708+ setSoulError ( message ) ;
2709+ } finally {
2710+ setSoulStatusBusy ( false ) ;
2711+ }
2712+ } ;
2713+
2714+ const activeSoulStatus = createMemo ( ( ) => {
2715+ const id = workspaceStore . activeWorkspaceId ( ) ;
2716+ if ( ! id ) return null ;
2717+ return soulStatusByWorkspaceId ( ) [ id ] ?? null ;
2718+ } ) ;
2719+
2720+ let lastSoulRefreshKey = "" ;
2721+ createEffect ( ( ) => {
2722+ const status = openworkServerStatus ( ) ;
2723+ const hasClient = Boolean ( openworkServerClient ( ) ) ;
2724+ const activeWorkspaceId = workspaceStore . activeWorkspaceId ( ) ;
2725+ const workspacesKey = workspaceStore
2726+ . workspaces ( )
2727+ . map ( ( workspace ) => {
2728+ const root = workspace . workspaceType === "local"
2729+ ? workspace . path ?. trim ( ) ?? ""
2730+ : workspace . directory ?. trim ( ) ?? workspace . path ?. trim ( ) ?? "" ;
2731+ return [ workspace . id , workspace . workspaceType , workspace . remoteType ?? "" , root , workspace . openworkWorkspaceId ?? "" ] . join ( "|" ) ;
2732+ } )
2733+ . join ( ";" ) ;
2734+ const key = [ status , hasClient ? "1" : "0" , activeWorkspaceId , workspacesKey ] . join ( "::" ) ;
2735+ if ( key === lastSoulRefreshKey ) return ;
2736+ lastSoulRefreshKey = key ;
2737+ void refreshSoulData ( ) . catch ( ( ) => undefined ) ;
2738+ } ) ;
2739+
25742740 createEffect ( ( ) => {
25752741 if ( ! isTauriRuntime ( ) ) return ;
25762742 workspaceStore . activeWorkspaceId ( ) ;
@@ -3539,6 +3705,13 @@ export default function App() {
35393705 }
35403706 }
35413707
3708+ function runSoulPrompt ( promptText : string ) {
3709+ const text = promptText . trim ( ) ;
3710+ if ( ! text ) return ;
3711+ setPrompt ( text ) ;
3712+ void createSessionAndOpen ( ) ;
3713+ }
3714+
35423715
35433716 onMount ( async ( ) => {
35443717 const startupPref = readStartupPreference ( ) ;
@@ -4393,6 +4566,14 @@ export default function App() {
43934566 refreshScheduledJobs : ( options ?: { force ?: boolean } ) =>
43944567 refreshScheduledJobs ( options ) . catch ( ( ) => undefined ) ,
43954568 deleteScheduledJob,
4569+ soulStatusByWorkspaceId : soulStatusByWorkspaceId ( ) ,
4570+ activeSoulStatus : activeSoulStatus ( ) ,
4571+ activeSoulHeartbeats : activeSoulHeartbeats ( ) ,
4572+ soulStatusBusy : soulStatusBusy ( ) ,
4573+ soulHeartbeatsBusy : soulHeartbeatsBusy ( ) ,
4574+ soulError : soulError ( ) ,
4575+ refreshSoulData : ( options ?: { force ?: boolean } ) => refreshSoulData ( options ) . catch ( ( ) => undefined ) ,
4576+ runSoulPrompt,
43964577 activeWorkspaceRoot : workspaceStore . activeWorkspaceRoot ( ) . trim ( ) ,
43974578 refreshSkills : ( options ?: { force ?: boolean } ) => refreshSkills ( options ) . catch ( ( ) => undefined ) ,
43984579 refreshHubSkills : ( options ?: { force ?: boolean } ) => refreshHubSkills ( options ) . catch ( ( ) => undefined ) ,
@@ -4591,6 +4772,7 @@ export default function App() {
45914772 retryLastPrompt : retryLastPrompt ,
45924773 newTaskDisabled : newTaskDisabled ( ) ,
45934774 workspaceSessionGroups : sidebarWorkspaceGroups ( ) ,
4775+ soulStatusByWorkspaceId : soulStatusByWorkspaceId ( ) ,
45944776 openRenameWorkspace,
45954777 selectSession : selectSession ,
45964778 messages : visibleMessages ( ) ,
@@ -4654,6 +4836,7 @@ export default function App() {
46544836
46554837 const dashboardTabs = new Set < DashboardTab > ( [
46564838 "scheduled" ,
4839+ "soul" ,
46574840 "skills" ,
46584841 "plugins" ,
46594842 "mcp" ,
0 commit comments