Add a Save to Mac button for files in the Files tab

This commit is contained in:
Ian Gulliver
2026-10-23 12:17:17 -07:00
parent 1383bd6ae5
commit dc2fcc6075
4 changed files with 240 additions and 95 deletions
+16 -3
View File
@@ -228,11 +228,24 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
if !ok {
return
}
if params.Path == "" {
serveRaw(w, r, t.WorktreePath, params.Path)
}
func (s *Server) GetProjectRaw(w http.ResponseWriter, r *http.Request, projectID string, params api.GetProjectRawParams) {
p, err := s.store.GetProject(r.Context(), projectID)
if err != nil {
writeStoreError(w, err)
return
}
serveRaw(w, r, p.RepoPath, params.Path)
}
func serveRaw(w http.ResponseWriter, r *http.Request, root, rel string) {
if rel == "" {
writeError(w, http.StatusBadRequest, errors.New("path is required"))
return
}
name, full := taskPath(t.WorktreePath, params.Path)
name, full := taskPath(root, rel)
f, err := os.Open(full)
if err != nil {
@@ -247,7 +260,7 @@ func (s *Server) GetTaskRaw(w http.ResponseWriter, r *http.Request, taskID strin
return
}
if !fi.Mode().IsRegular() {
writeError(w, http.StatusBadRequest, fmt.Errorf("%s is not a regular file", params.Path))
writeError(w, http.StatusBadRequest, fmt.Errorf("%s is not a regular file", rel))
return
}