Fix file path format and initialization issues
- Remove leading slash from file paths (use relative paths from workspace) - Server expects relative paths like 'file.md' not '/file.md' - Convert isInitialized from let to signal to persist across renders - Fix file picker not showing files on first open - Paths from find.files() are already relative to workspace
This commit is contained in:
@@ -53,17 +53,16 @@ export function createFileAttachment(
|
||||
mime: string = "text/plain",
|
||||
data?: Uint8Array,
|
||||
): Attachment {
|
||||
const absolutePath = path.startsWith("/") ? path : `/${path}`
|
||||
return {
|
||||
id: crypto.randomUUID(),
|
||||
type: "file",
|
||||
display: `@${filename}`,
|
||||
url: `file://${absolutePath}`,
|
||||
url: path,
|
||||
filename,
|
||||
mediaType: mime,
|
||||
source: {
|
||||
type: "file",
|
||||
path: absolutePath,
|
||||
path: path,
|
||||
mime,
|
||||
data,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user