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:
Shantur Rathore
2025-10-24 00:50:30 +01:00
parent 26ab3e066f
commit b6dc4ba249
2 changed files with 6 additions and 7 deletions

View File

@@ -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,
},