@@ -3,6 +3,7 @@ import { useWorkspaces } from "../../workspaces/hooks/useWorkspaces";
33import type { AppSettings , WorkspaceInfo } from "../../../types" ;
44import type { DebugEntry } from "../../../types" ;
55import { useWorkspaceDialogs } from "./useWorkspaceDialogs" ;
6+ import { isMobilePlatform } from "../../../utils/platformPaths" ;
67
78type WorkspaceControllerOptions = {
89 appSettings : AppSettings ;
@@ -34,29 +35,52 @@ export function useWorkspaceController({
3435 updateMobileRemoteWorkspacePathInput,
3536 cancelMobileRemoteWorkspacePathPrompt,
3637 submitMobileRemoteWorkspacePathPrompt,
38+ appendMobileRemoteWorkspacePathFromRecent,
39+ rememberRecentMobileRemoteWorkspacePaths,
3740 showAddWorkspacesResult,
3841 confirmWorkspaceRemoval,
3942 confirmWorktreeRemoval,
4043 showWorkspaceRemovalError,
4144 showWorktreeRemovalError,
4245 } = useWorkspaceDialogs ( ) ;
4346
44- const addWorkspacesFromPaths = useCallback (
45- async ( paths : string [ ] ) : Promise < WorkspaceInfo | null > => {
47+ const runAddWorkspacesFromPaths = useCallback (
48+ async (
49+ paths : string [ ] ,
50+ options ?: { rememberMobileRemoteRecents ?: boolean } ,
51+ ) => {
4652 const result = await addWorkspacesFromPathsCore ( paths ) ;
4753 await showAddWorkspacesResult ( result ) ;
54+ if ( options ?. rememberMobileRemoteRecents && result . added . length > 0 ) {
55+ rememberRecentMobileRemoteWorkspacePaths ( result . added . map ( ( entry ) => entry . path ) ) ;
56+ }
57+ return result ;
58+ } ,
59+ [
60+ addWorkspacesFromPathsCore ,
61+ rememberRecentMobileRemoteWorkspacePaths ,
62+ showAddWorkspacesResult ,
63+ ] ,
64+ ) ;
65+
66+ const addWorkspacesFromPaths = useCallback (
67+ async ( paths : string [ ] ) : Promise < WorkspaceInfo | null > => {
68+ const result = await runAddWorkspacesFromPaths ( paths ) ;
4869 return result . firstAdded ;
4970 } ,
50- [ addWorkspacesFromPathsCore , showAddWorkspacesResult ] ,
71+ [ runAddWorkspacesFromPaths ] ,
5172 ) ;
5273
5374 const addWorkspace = useCallback ( async ( ) : Promise < WorkspaceInfo | null > => {
5475 const paths = await requestWorkspacePaths ( appSettings . backendMode ) ;
5576 if ( paths . length === 0 ) {
5677 return null ;
5778 }
58- return addWorkspacesFromPaths ( paths ) ;
59- } , [ addWorkspacesFromPaths , appSettings . backendMode , requestWorkspacePaths ] ) ;
79+ const result = await runAddWorkspacesFromPaths ( paths , {
80+ rememberMobileRemoteRecents : isMobilePlatform ( ) && appSettings . backendMode === "remote" ,
81+ } ) ;
82+ return result . firstAdded ;
83+ } , [ appSettings . backendMode , requestWorkspacePaths , runAddWorkspacesFromPaths ] ) ;
6084
6185 const removeWorkspace = useCallback (
6286 async ( workspaceId : string ) => {
@@ -96,6 +120,7 @@ export function useWorkspaceController({
96120 updateMobileRemoteWorkspacePathInput,
97121 cancelMobileRemoteWorkspacePathPrompt,
98122 submitMobileRemoteWorkspacePathPrompt,
123+ appendMobileRemoteWorkspacePathFromRecent,
99124 removeWorkspace,
100125 removeWorktree,
101126 } ;
0 commit comments