mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 02:04:22 +01:00
fix: attachment bugs (#1335)
This commit is contained in:
@@ -419,9 +419,7 @@ export namespace Session {
|
|||||||
case "file:":
|
case "file:":
|
||||||
// have to normalize, symbol search returns absolute paths
|
// have to normalize, symbol search returns absolute paths
|
||||||
// Decode the pathname since URL constructor doesn't automatically decode it
|
// Decode the pathname since URL constructor doesn't automatically decode it
|
||||||
const pathname = decodeURIComponent(url.pathname)
|
const filePath = decodeURIComponent(url.pathname)
|
||||||
const relativePath = pathname.replace(app.path.cwd, ".")
|
|
||||||
const filePath = path.join(app.path.cwd, relativePath)
|
|
||||||
|
|
||||||
if (part.mime === "text/plain") {
|
if (part.mime === "text/plain") {
|
||||||
let offset: number | undefined = undefined
|
let offset: number | undefined = undefined
|
||||||
@@ -501,7 +499,7 @@ export namespace Session {
|
|||||||
messageID: userMsg.id,
|
messageID: userMsg.id,
|
||||||
sessionID: input.sessionID,
|
sessionID: input.sessionID,
|
||||||
type: "text",
|
type: "text",
|
||||||
text: `Called the Read tool with the following input: {\"filePath\":\"${pathname}\"}`,
|
text: `Called the Read tool with the following input: {\"filePath\":\"${filePath}\"}`,
|
||||||
synthetic: true,
|
synthetic: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -732,7 +731,7 @@ func (m *editorComponent) createAttachmentFromFile(filePath string) *attachment.
|
|||||||
ID: uuid.NewString(),
|
ID: uuid.NewString(),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
Display: "@" + filePath,
|
Display: "@" + filePath,
|
||||||
URL: fmt.Sprintf("file://./%s", filePath),
|
URL: fmt.Sprintf("file://%s", absolutePath),
|
||||||
Filename: filePath,
|
Filename: filePath,
|
||||||
MediaType: mediaType,
|
MediaType: mediaType,
|
||||||
Source: &attachment.FileSource{
|
Source: &attachment.FileSource{
|
||||||
@@ -783,7 +782,7 @@ func (m *editorComponent) createAttachmentFromPath(filePath string) *attachment.
|
|||||||
ID: uuid.NewString(),
|
ID: uuid.NewString(),
|
||||||
Type: "file",
|
Type: "file",
|
||||||
Display: "@" + filePath,
|
Display: "@" + filePath,
|
||||||
URL: fmt.Sprintf("file://./%s", url.PathEscape(filePath)),
|
URL: fmt.Sprintf("file://%s", absolutePath),
|
||||||
Filename: filePath,
|
Filename: filePath,
|
||||||
MediaType: mediaType,
|
MediaType: mediaType,
|
||||||
Source: &attachment.FileSource{
|
Source: &attachment.FileSource{
|
||||||
|
|||||||
Reference in New Issue
Block a user