@@ -65,16 +65,23 @@ import {
6565 workspaceBootstrap ,
6666 workspaceCreate ,
6767 workspaceCreateRemote ,
68+ workspaceExportConfig ,
69+ workspaceForget ,
6870 workspaceSetRuntimeActive ,
6971 workspaceSetSelected ,
72+ workspaceUpdateDisplayName ,
7073 type WorkspaceInfo ,
74+ revealDesktopItemInDir ,
7175} from "../../app/lib/desktop" ;
7276import { isDesktopProviderBlocked } from "../../app/cloud/desktop-app-restrictions" ;
7377import { useCheckDesktopRestriction , useDesktopConfig } from "../domains/cloud/desktop-config-provider" ;
7478import { useCloudProviderAutoSync } from "../domains/cloud/use-cloud-provider-auto-sync" ;
7579import { isDesktopRuntime , isElectronRuntime , isMacPlatform , normalizeDirectoryPath , safeStringify } from "../../app/utils" ;
7680import { CreateRemoteWorkspaceModal } from "../domains/workspace/create-remote-workspace-modal" ;
7781import { CreateWorkspaceModal } from "../domains/workspace/create-workspace-modal" ;
82+ import { RenameWorkspaceModal } from "../domains/workspace/rename-workspace-modal" ;
83+ import { ShareWorkspaceModal } from "../domains/workspace/share-workspace-modal" ;
84+ import { useShareWorkspaceState } from "../domains/workspace/share-workspace-state" ;
7885import { useRemoteWorkspaceConnectionEditor } from "../domains/workspace/use-remote-workspace-connection-editor" ;
7986import {
8087 diagnoseRemoteWorkspaceTaskLoadFailure ,
@@ -374,6 +381,10 @@ export function SettingsRoute() {
374381 const [ createWorkspaceError , setCreateWorkspaceError ] = useState < string | null > ( null ) ;
375382 const [ createWorkspaceRemoteBusy , setCreateWorkspaceRemoteBusy ] = useState ( false ) ;
376383 const [ createWorkspaceRemoteError , setCreateWorkspaceRemoteError ] = useState < string | null > ( null ) ;
384+ const [ renameWorkspaceId , setRenameWorkspaceId ] = useState < string | null > ( null ) ;
385+ const [ renameWorkspaceTitle , setRenameWorkspaceTitle ] = useState ( "" ) ;
386+ const [ renameWorkspaceBusy , setRenameWorkspaceBusy ] = useState ( false ) ;
387+ const [ exportWorkspaceBusy , setExportWorkspaceBusy ] = useState ( false ) ;
377388 const [ modelPickerOpen , setModelPickerOpen ] = useState ( false ) ;
378389 const [ modelPickerQuery , setModelPickerQuery ] = useState ( "" ) ;
379390 const [ modelOptions , setModelOptions ] = useState < ModelOption [ ] > ( [ ] ) ;
@@ -628,6 +639,16 @@ export function SettingsRoute() {
628639 const providerAuthSnapshot = useProviderAuthStoreSnapshot ( providerAuthStore ) ;
629640 useExtensionsStoreSnapshot ( extensionsStore ) ;
630641
642+ const shareWorkspaceState = useShareWorkspaceState ( {
643+ workspaces,
644+ openworkServerHostInfo : openworkServerSnapshot . openworkServerHostInfo ,
645+ openworkServerSettings : openworkServerSnapshot . openworkServerSettings ,
646+ engineInfo : null ,
647+ exportWorkspaceBusy,
648+ openLink : ( url ) => platform . openLink ( url ) ,
649+ workspaceLabel,
650+ } ) ;
651+
631652 const debugViewProps = useDebugViewModel ( {
632653 developerMode,
633654 openworkServerStore,
@@ -1138,6 +1159,85 @@ export function SettingsRoute() {
11381159 setCreateWorkspaceOpen ( true ) ;
11391160 } ;
11401161
1162+ const handleOpenRenameWorkspace = useCallback ( ( workspaceId : string ) => {
1163+ const workspace = workspaces . find ( ( item ) => item . id === workspaceId ) ;
1164+ if ( ! workspace ) return ;
1165+ setRenameWorkspaceId ( workspaceId ) ;
1166+ setRenameWorkspaceTitle ( workspaceLabel ( workspace ) ) ;
1167+ } , [ workspaces ] ) ;
1168+
1169+ const handleSaveRenameWorkspace = useCallback ( async ( ) => {
1170+ if ( ! renameWorkspaceId ) return ;
1171+ const trimmed = renameWorkspaceTitle . trim ( ) ;
1172+ if ( ! trimmed ) return ;
1173+ setRenameWorkspaceBusy ( true ) ;
1174+ try {
1175+ if ( isDesktopRuntime ( ) ) {
1176+ await workspaceUpdateDisplayName ( {
1177+ workspaceId : renameWorkspaceId ,
1178+ displayName : trimmed ,
1179+ } ) . catch ( ( ) => undefined ) ;
1180+ }
1181+ if ( openworkClient ) {
1182+ await openworkClient
1183+ . updateWorkspaceDisplayName ( renameWorkspaceId , trimmed )
1184+ . catch ( ( ) => undefined ) ;
1185+ }
1186+ setRenameWorkspaceId ( null ) ;
1187+ setRenameWorkspaceTitle ( "" ) ;
1188+ await refreshRouteState ( ) ;
1189+ } finally {
1190+ setRenameWorkspaceBusy ( false ) ;
1191+ }
1192+ } , [ openworkClient , refreshRouteState , renameWorkspaceId , renameWorkspaceTitle ] ) ;
1193+
1194+ const handleRevealWorkspace = useCallback ( async ( workspaceId : string ) => {
1195+ const workspace = workspaces . find ( ( item ) => item . id === workspaceId ) ;
1196+ const path = workspace ?. path ?. trim ( ) ;
1197+ if ( ! path || ! isDesktopRuntime ( ) ) return ;
1198+ await revealDesktopItemInDir ( path ) . catch ( ( ) => undefined ) ;
1199+ } , [ workspaces ] ) ;
1200+
1201+ const handleExportWorkspaceConfig = useCallback ( async ( workspaceId : string ) => {
1202+ if ( ! isDesktopRuntime ( ) ) return ;
1203+ const workspace = workspaces . find ( ( item ) => item . id === workspaceId ) ?? null ;
1204+ if ( ! workspace ) return ;
1205+ const outputPath = await pickDirectory ( {
1206+ title : `Choose where to export ${ workspaceLabel ( workspace ) } ` ,
1207+ } ) ;
1208+ const targetPath = Array . isArray ( outputPath ) ? outputPath [ 0 ] : outputPath ;
1209+ if ( ! targetPath ) return ;
1210+ setExportWorkspaceBusy ( true ) ;
1211+ try {
1212+ await workspaceExportConfig ( { workspaceId, outputPath : targetPath } ) ;
1213+ await revealDesktopItemInDir ( targetPath ) . catch ( ( ) => undefined ) ;
1214+ } finally {
1215+ setExportWorkspaceBusy ( false ) ;
1216+ }
1217+ } , [ workspaces ] ) ;
1218+
1219+ const handleForgetWorkspace = useCallback ( async ( workspaceId : string ) => {
1220+ if ( typeof window !== "undefined" ) {
1221+ const message = t ( "workspace_list.remove_confirm" ) || "Remove this workspace from the sidebar?" ;
1222+ if ( ! window . confirm ( message ) ) return ;
1223+ }
1224+ if ( isDesktopRuntime ( ) ) {
1225+ await workspaceForget ( workspaceId ) . catch ( ( ) => undefined ) ;
1226+ }
1227+ if ( openworkClient ) {
1228+ await openworkClient . deleteWorkspace ( workspaceId ) . catch ( ( ) => undefined ) ;
1229+ }
1230+ if ( selectedWorkspaceId === workspaceId ) {
1231+ const nextWorkspace = workspaces . find ( ( workspace ) => workspace . id !== workspaceId ) ;
1232+ const nextId = nextWorkspace ?. id ?? "" ;
1233+ setSelectedWorkspaceId ( nextId ) ;
1234+ if ( nextId ) {
1235+ await workspaceSetSelected ( nextId ) . catch ( ( ) => undefined ) ;
1236+ }
1237+ }
1238+ await refreshRouteState ( ) ;
1239+ } , [ openworkClient , refreshRouteState , selectedWorkspaceId , workspaces ] ) ;
1240+
11411241 const handleCreateWorkspace = async ( preset : WorkspacePreset , folder : string | null ) => {
11421242 if ( ! folder ) return ;
11431243 setCreateWorkspaceBusy ( true ) ;
@@ -1586,13 +1686,13 @@ export function SettingsRoute() {
15861686 } ,
15871687 onOpenSession : ( _workspaceId , sessionId ) => navigate ( `/session/${ sessionId } ` ) ,
15881688 onCreateTaskInWorkspace : ( ) => navigate ( "/session" ) ,
1589- onOpenRenameWorkspace : ( ) => { } ,
1590- onShareWorkspace : ( ) => { } ,
1591- onRevealWorkspace : ( ) => { } ,
1689+ onOpenRenameWorkspace : handleOpenRenameWorkspace ,
1690+ onShareWorkspace : shareWorkspaceState . openShareWorkspace ,
1691+ onRevealWorkspace : ( id ) => void handleRevealWorkspace ( id ) ,
15921692 onRecoverWorkspace : ( workspaceId ) => runRemoteWorkspaceConnectionCheck ( workspaceId , "recover" ) ,
15931693 onTestWorkspaceConnection : ( workspaceId ) => runRemoteWorkspaceConnectionCheck ( workspaceId , "test" ) ,
15941694 onEditWorkspaceConnection : remoteWorkspaceConnectionEditor . open ,
1595- onForgetWorkspace : ( ) => { } ,
1695+ onForgetWorkspace : ( id ) => void handleForgetWorkspace ( id ) ,
15961696 onOpenCreateWorkspace : handleOpenCreateWorkspace ,
15971697 } }
15981698 onClose = { ( ) => navigate ( "/session" ) }
@@ -1643,6 +1743,39 @@ export function SettingsRoute() {
16431743 remoteSubmitting = { createWorkspaceRemoteBusy }
16441744 remoteError = { createWorkspaceRemoteError }
16451745 />
1746+ < RenameWorkspaceModal
1747+ open = { renameWorkspaceId !== null }
1748+ title = { renameWorkspaceTitle }
1749+ busy = { renameWorkspaceBusy }
1750+ canSave = { ! renameWorkspaceBusy && renameWorkspaceTitle . trim ( ) . length > 0 }
1751+ onClose = { ( ) => {
1752+ if ( renameWorkspaceBusy ) return ;
1753+ setRenameWorkspaceId ( null ) ;
1754+ setRenameWorkspaceTitle ( "" ) ;
1755+ } }
1756+ onSave = { ( ) => void handleSaveRenameWorkspace ( ) }
1757+ onTitleChange = { setRenameWorkspaceTitle }
1758+ />
1759+ { shareWorkspaceState . shareWorkspaceOpen ? (
1760+ < ShareWorkspaceModal
1761+ open
1762+ onClose = { shareWorkspaceState . closeShareWorkspace }
1763+ workspaceName = { shareWorkspaceState . shareWorkspaceName }
1764+ workspaceDetail = { shareWorkspaceState . shareWorkspaceDetail }
1765+ fields = { shareWorkspaceState . shareFields }
1766+ note = { shareWorkspaceState . shareNote }
1767+ onExportConfig = {
1768+ shareWorkspaceState . exportDisabledReason === null
1769+ ? ( ) => {
1770+ const id = shareWorkspaceState . shareWorkspaceId ;
1771+ if ( ! id ) return ;
1772+ void handleExportWorkspaceConfig ( id ) ;
1773+ }
1774+ : undefined
1775+ }
1776+ exportDisabledReason = { shareWorkspaceState . exportDisabledReason }
1777+ />
1778+ ) : null }
16461779 < CreateRemoteWorkspaceModal
16471780 open = { remoteWorkspaceConnectionEditor . workspace !== null }
16481781 onClose = { remoteWorkspaceConnectionEditor . close }
0 commit comments