Technical docs
Cowork
Overview
Support reference for the org Cowork route (`/cowork`).
What Cowork is
- Storage-backed workspace for opening org files and chatting with an AI teammate side-by-side.
- Storage remains the source of truth: uploads, deletes, shares, and edits affect the same org files used elsewhere.
- Opening a file from `/storage` routes into Cowork with `/cowork?path=...`.
Layout
- Desktop: collapsible tree, document/media panel, and a right chat column with three desktop states:
- `Chats` history view in the sidebar slot
- active chat view after the user opens a conversation or starts a new one
- fully collapsed chat panel
- Desktop Cowork persists the tree, document, and chat panel widths in local storage and restores them on revisit.
- Desktop resize handles between tree↔document and document↔chat highlight on hover and while dragging.
- Desktop users can collapse or expand the chat panel from the file header area.
- Mobile: full-screen panels using the shared mobile bottom bar: `Menu`, `Tree`, `Doc`, `Chat`, `History`.
- Mobile opens on the `History` panel by default. The universal mobile `Chats` item opens `/cowork?coworkPanel=history`; `Files` opens `/cowork?coworkPanel=tree`.
- Mobile supports swipe navigation between panels, arrow-key tab movement in the Cowork bar, and chat links back into Cowork documents switch the mobile view to `Doc`.
- While the viewport mode is being detected, Cowork shows a `Loading workspace` skeleton instead of rendering the wrong shell first.
- Cowork is keyed by the current org in the route layer, so switching orgs resets the workspace state instead of carrying the previous org's selection forward.
- If users return to Cowork without a `?path=` deep link, the workspace can restore the last selected file for that org. On mobile, restore waits until the `Doc` panel is visible, then opens the restored file in `Doc`.
Tree behavior
- Tree collapse state is stored in local storage under the Cowork tree-collapse key.
- Expanded folder state is also stored per organization in local storage and restored when users revisit Cowork.
- A `Recent` section can appear above the storage tree.
- Recent files are tracked per organization in local storage.
- The current recent-files list stores up to `5` paths.
- The `Recent` section has its own collapsed state, also persisted per organization.
- Recent entries are updated when a remembered file is renamed or moved, and removed when a remembered file or containing folder is deleted.
- A `?path=...` deep link opens that item, forces the tree open for the load, then removes the query param from the URL.
- Dragging files or folders from outside the app onto a folder in the tree uploads into that folder.
- Tree items can also be dragged within the Cowork tree to move them to another folder.
- Dragging a file onto another file moves it into that file's parent folder.
- Dragging a folder to the tree root moves it to root.
- Dragging a folder onto itself or into one of its descendants is blocked.
- Tree context menu uses storage actions for copy path, rename, new subfolder, share, delete, and download.
- Rename is available for both files and folders.
- File rows download the selected file directly.
- Folder rows download the selected folder as a browser-generated `.zip` archive.
- Folder zip downloads currently fail if the folder contains more than `500` files.
File handling
- Editable in Cowork: existing `.txt` and `.md` only.
- Spreadsheet fallback: `.csv` and `.xlsx` open a download-only spreadsheet panel.
- Inline media preview:
- Images: `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.svg`, `.bmp`, `.avif`
- Video: `.mp4`, `.webm`, `.ogv`
- Audio: `.mp3`, `.wav`, `.ogg`, `.aac`, `.flac`, `.m4a`, `.opus`
- Other files can still be selected from the tree, but Cowork shows an unsupported preview state with `Download`.
- Cowork document states include empty selection, loading, unsupported preview, too-large preview, not found, generic error, and ready.
- Spreadsheet fetches are blocked for previews above `10 MB`, so large spreadsheets fall back to download-only behavior.
Document editing
- Cowork edits existing files only; it does not create new documents through the editor endpoint.
- Autosave runs after about `1s` of inactivity.
- Save also runs on blur and `Cmd+S` / `Ctrl+S`.
- Header status states: `Saving…`, `Saved`, `Updated remotely`, `Save failed`.
- When no save-status message is showing, the document header path uses dynamic middle truncation and keeps the filename tail visible.
- If the open file is updated through websocket events, Cowork reloads it and briefly shows `Updated remotely`.
- If the open file is deleted, Cowork clears the selection and removes the stored restored-path value for that org.
- Save failures show an inline retry hint that points users back to `Cmd+S` / `Ctrl+S`.
- Current code confirms `.txt` and `.md` path restrictions. The file-content endpoint itself is for existing files only; the `10 MB` limit is enforced on upload and spreadsheet preview, not as a separate confirmed document-edit rule.
- Cowork document live refresh listens to `storage_file.updated`, `storage_file.deleted`, `storage_file.renamed`, and `storage_file.moved`.
- When the currently open file is renamed or moved, Cowork remaps the active selection to the new path instead of dropping it.
- If a rename or move changes which viewer type should be used, Cowork switches to the correct viewer for the new path.
- If a rename or move happens while the document is still loading, Cowork reloads the new path. If a save was already in progress, Cowork re-queues the save against the remapped path.
- Spreadsheet and media selections clear on delete. Their selected paths also remap on rename and move.
- On revisit without an explicit deep link, Cowork checks whether the stored selected file still exists before restoring it.
Header actions
- Current document/media/spreadsheet header menu actions are `Copy link` and `Download`.
- When a document path is shown in the header, each ancestor folder segment is clickable and reopens Cowork at that folder path.
- The final file segment stays non-clickable.
- On desktop, the same header area also exposes the chat-panel collapse/expand toggle.
- On mobile, the document header keeps tree access as `Open file tree`, and panel navigation otherwise happens through the bottom bar.
Chat behavior
- Users must select an AI teammate before chatting.
- The picker uses active AI teammates only.
- The selected teammate is persisted per org and user in local storage.
- Conversation actions are `History` and `Settings`, plus `New conversation` in the overflow menu once there is an active conversation to reset.
- When a teammate is selected, the chat header also shows a dedicated `New conversation` button.
- On mobile, `History` is also a dedicated bottom-tab panel.
- On desktop, the chat column opens in a `Chats` history view until the user opens a conversation or starts a fresh chat.
- Desktop and mobile both use the same shared history/chat module and the same merged Cowork history list across active AI teammates.
- Cowork history only shows AI-teammate conversations for active teammates in the current org. This is intentionally the same teammate-only filtering used by the shared `Chats` surface.
- The history view shows recent-teammate chips for starting a new chat without opening an existing thread.
- History includes a `Search` field.
- Entering 3 or more characters automatically searches AI-teammate internal-chat conversations for the current org user.
- Search results can match conversation titles or message content, and message matches can show an excerpt with the matched text highlighted.
- Selecting a history row opens that conversation, switches the selected teammate, and shows the active chat view.
- Starting a fresh chat from a teammate chip switches to that teammate and explicitly opens a blank conversation.
- The history screen stays mounted while the chat screen is active, so returning to history keeps the current search/list state.
- When a stored file or deep-linked file is auto-opened on mobile, Cowork switches to the `Doc` panel automatically.
- Voice mode is available only when the selected teammate has a `tts_model`.
- Cowork uses the shared internal-chat surface with the welcome state suppressed inside the Cowork panel.
Storage APIs used by Cowork
- `GET /api/organizations/{orgId}/storage?path=...`
- `POST /api/organizations/{orgId}/storage/upload`
- `DELETE /api/organizations/{orgId}/storage/file?path=...`
- `POST /api/organizations/{orgId}/storage/folder`
- `POST /api/organizations/{orgId}/storage/folder/rename`
- `POST /api/organizations/{orgId}/storage/folder/move`
- `GET /api/organizations/{orgId}/storage/folder/share?path=...`
- `POST /api/organizations/{orgId}/storage/folder/share`
- `DELETE /api/organizations/{orgId}/storage/folder/share`
- `GET /api/organizations/{orgId}/storage/file/content?path=...`
- `PUT /api/organizations/{orgId}/storage/file/content`
- `GET /api/organizations/{orgId}/internal-chat/conversations/search?q=...&limit=...`
Support notes
- Cowork is the primary open-file experience for non-folder Storage items.
- Spreadsheet preview is unavailable in Cowork today; spreadsheets are download-only there.
- Folder sharing in Cowork uses the same folder-sharing rules as Storage, including root-share restrictions.