fix(filemanager): return raw file content in FSRead to avoid embedded line numbers

The FSRead handler was using client.ReadFile() which formats each line
with a line number prefix (for MCP AI tools). Switch to client.ReadRaw()
so the file viewer gets unmodified content — fixes duplicate line numbers
in the Monaco editor.
This commit is contained in:
Acbox
2026-03-11 17:24:39 +08:00
parent 2debfb496c
commit 70252124ba
+9 -3
View File
@@ -256,15 +256,21 @@ func (h *ContainerdHandler) FSRead(c echo.Context) error {
return echo.NewHTTPError(http.StatusServiceUnavailable, fmt.Sprintf("container not reachable: %v", err))
}
resp, err := client.ReadFile(ctx, containerPath, 0, 0)
rc, err := client.ReadRaw(ctx, containerPath)
if err != nil {
return fsHTTPError(err)
}
defer func() { _ = rc.Close() }()
data, err := io.ReadAll(rc)
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "failed to read file")
}
return c.JSON(http.StatusOK, FSReadResponse{
Path: containerPath,
Content: resp.GetContent(),
Size: int64(len(resp.GetContent())),
Content: string(data),
Size: int64(len(data)),
})
}