@@ -57,7 +57,7 @@ import { useSessionLayout } from "@/pages/session/session-layout"
5757import { createSessionTabs } from "@/pages/session/helpers"
5858import { createTextFragment , getCursorPosition , setCursorPosition , setRangeEdge } from "./prompt-input/editor-dom"
5959import { createPromptAttachments } from "./prompt-input/attachments"
60- import { ACCEPTED_FILE_TYPES } from "./prompt-input/files"
60+ import { ACCEPTED_FILE_TYPES , pickAttachmentFiles } from "./prompt-input/files"
6161import {
6262 canNavigateHistoryAtCursor ,
6363 navigatePromptHistory ,
@@ -73,6 +73,8 @@ import { PromptContextItems } from "./prompt-input/context-items"
7373import { PromptImageAttachments } from "./prompt-input/image-attachments"
7474import { PromptDragOverlay } from "./prompt-input/drag-overlay"
7575import { promptPlaceholder } from "./prompt-input/placeholder"
76+ import { useDirectoryPicker } from "./directory-picker"
77+ import { showToast } from "@/utils/toast"
7678import { ImagePreview } from "@opencode-ai/ui/image-preview"
7779import { useQueries } from "@tanstack/solid-query"
7880import { useQueryOptions } from "@/context/server-sync"
@@ -140,6 +142,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
140142 const permission = usePermission ( )
141143 const language = useLanguage ( )
142144 const platform = usePlatform ( )
145+ const pickDirectory = useDirectoryPicker ( )
143146 const settings = useSettings ( )
144147 const { params, tabs, view } = useSessionLayout ( )
145148 let editorRef ! : HTMLDivElement
@@ -468,7 +471,18 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
468471
469472 const pick = ( ) => {
470473 if ( server . isLocal ( ) ) {
471- fileInputRef ?. click ( )
474+ pickAttachmentFiles ( {
475+ picker : platform . openAttachmentPickerDialog ,
476+ directory : ( ) => sdk . directory ,
477+ fallback : ( ) => fileInputRef ?. click ( ) ,
478+ onFile : addAttachment ,
479+ onError : ( error ) =>
480+ showToast ( {
481+ variant : "error" ,
482+ title : language . t ( "common.requestFailed" ) ,
483+ description : error instanceof Error ? error . message : String ( error ) ,
484+ } ) ,
485+ } )
472486 return
473487 }
474488 void import ( "@/components/dialog-select-file" ) . then ( ( module ) =>
@@ -1094,7 +1108,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
10941108 return true
10951109 }
10961110
1097- const { addAttachments, removeAttachment, handlePaste } = createPromptAttachments ( {
1111+ const { addAttachment , addAttachments, removeAttachment, handlePaste } = createPromptAttachments ( {
10981112 editor : ( ) => editorRef ,
10991113 isDialogActive : ( ) => ! ! dialog . active ,
11001114 setDraggingType : ( type ) => setStore ( "draggingType" , type ) ,
@@ -1385,23 +1399,18 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
13851399 server . projects . touch ( worktree )
13861400 navigate ( `/${ base64Encode ( worktree ) } /session` )
13871401 }
1388- const addProject = async ( ) => {
1402+ const addProject = ( ) => {
13891403 const conn = server . current
13901404 if ( ! conn ) return
13911405 const select = ( result : string | string [ ] | null ) => {
13921406 const directory = Array . isArray ( result ) ? result [ 0 ] : result
13931407 if ( ! directory ) return
13941408 selectProject ( directory )
13951409 }
1396- if ( platform . openDirectoryPickerDialog && server . isLocal ( ) ) {
1397- select ( await platform . openDirectoryPickerDialog ( { title : language . t ( "command.project.open" ) } ) )
1398- return
1399- }
1400- void import ( "@/components/dialog-select-directory" ) . then ( ( x ) => {
1401- dialog . show (
1402- ( ) => < x . DialogSelectDirectory onSelect = { select } server = { conn } /> ,
1403- ( ) => select ( null ) ,
1404- )
1410+ pickDirectory ( {
1411+ server : conn ,
1412+ title : language . t ( "command.project.open" ) ,
1413+ onSelect : select ,
14051414 } )
14061415 }
14071416
0 commit comments