feat(app): Dateien-Panel im Dock (zwischen Chat und Code)
Neues 📁-Panel listet ALLE Projektdateien (/shared/projects/<id>/) — auch erzeugte Bilder, nicht nur Code; dieselben, die in der Projektliste als 📄 gezaehlt werden. Bild antippen → Vollbild-Vorschau; Textdatei → Text-Vorschau. - Brain: /projects/<id>/file?binary=1 → Base64 + MIME (fuer Bilder, max 8 MB). - App: brainApi.readProjectFileBinary; layout 'files'-Tile; Dock-Reihenfolge Chat · Dateien · Code · Desktop; FilesTile mit Bild-/Text-Modal. py/tsc clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+12
-1
@@ -912,13 +912,24 @@ def project_files(project_id: str):
|
||||
|
||||
|
||||
@app.get("/projects/{project_id}/file")
|
||||
def project_file(project_id: str, path: str):
|
||||
def project_file(project_id: str, path: str, binary: bool = False):
|
||||
base = _project_dir(project_id)
|
||||
target = os.path.realpath(os.path.join(base, path))
|
||||
if target != base and not target.startswith(base + os.sep):
|
||||
raise HTTPException(status_code=400, detail="Pfad ausserhalb des Projekts")
|
||||
if not os.path.isfile(target):
|
||||
raise HTTPException(status_code=404, detail="Datei nicht gefunden")
|
||||
# Binaer (z.B. Bilder) → Base64. Grosszuegigeres Limit als beim Text-Editor.
|
||||
if binary:
|
||||
import base64
|
||||
import mimetypes
|
||||
if os.path.getsize(target) > 8 * 1024 * 1024:
|
||||
raise HTTPException(status_code=413, detail="Datei zu gross (max 8 MB)")
|
||||
with open(target, "rb") as f:
|
||||
data = f.read()
|
||||
mime, _ = mimetypes.guess_type(target)
|
||||
return {"projectId": project_id, "path": path, "mime": mime or "application/octet-stream",
|
||||
"base64": base64.b64encode(data).decode("ascii")}
|
||||
if os.path.getsize(target) > _PROJECT_FILE_MAX:
|
||||
raise HTTPException(status_code=413, detail="Datei zu gross fuer den Editor")
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user