Skip to content

Workspace file preview limited to 1MB — should support up to 100MB #1425

Description

@ptone

Bug

When clicking a file path link in native chat to preview a workspace file, files larger than 1MB are rejected with:

File too large for editing (33.7 MB). Maximum is 1MB.

The limit should be 100MB to support common project artifacts (archives, logs, large source files).

Root cause

`pkg/hub/project_workspace_handlers.go:53`:
```go
const maxEditableFileSize = 1 * 1024 * 1024
```

When the workspace file API is called with `?format=json` (which the chat file preview and workspace editor use), the handler at line 471 checks `info.Size() > maxEditableFileSize` and returns a 400 error.

The file preview flow in chat:

  1. User clicks a file path link in a chat message
  2. `chat-thread.ts` calls `buildFileApiUrl()` → `GET /api/v1/projects/{id}/workspace/files/{path}?format=json`
  3. Backend handler reads the file, checks size against `maxEditableFileSize` (1MB), rejects if too large
  4. Error surfaces as red text in the preview dialog

Note: raw downloads (without `?format=json`) have no size limit — the Download button works regardless of file size.

Fix considerations

Raising `maxEditableFileSize` to 100MB affects two flows:

  1. Chat file preview (read-only inline view) — the path that's broken
  2. Workspace file editor (read-write inline editor) — the file-browser edit button

For the editor flow, 100MB may be excessive for in-browser editing. The fix may need to:

  • Raise the limit globally to 100MB (simplest), or
  • Separate the preview (read-only) and edit (read-write) limits, or
  • Add a `?mode=preview` query param that uses a higher limit than `?format=json` (which implies editable)

The frontend also has its own limits:

  • `chat-thread.ts:177`: `PATH_PREVIEW_MAX = 512 * 1024` — files above 512KB show "too large to preview inline" instead of content (but don't error — they show the download button)
  • `file-browser.ts:506`: `MAX_EDITABLE_FILE_SIZE = 1 * 1024 * 1024` — hides the edit button for files > 1MB

These frontend limits would also need adjustment for the full 100MB experience.

Files

  • `pkg/hub/project_workspace_handlers.go:53,471-472` — the backend 1MB limit and error
  • `web/src/components/shared/chat/chat-thread.ts:177,2402-2420` — frontend preview fetch and 512KB preview limit
  • `web/src/components/shared/file-browser.ts:506` — frontend editor size limit

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions