SDK v2 Phase 2: FilePreview registry, app drives, render surfaces
Radin committed
- Author
- Radin · radin@coline.appAug 10, 2026 at 18:02
- Committer
- Radin · radin@coline.appAug 10, 2026 at 18:02
- Parents
- 831bd592ea75
SDK v2 Phase 2: FilePreview registry, app drives, render surfaces
Files created by apps now render across surfaces through one registry,
and apps get their own drives (plan §9).
SDK (@colineapp/sdk/v2):
- render.surface protocol kind (server/render-surface.ts): one wire
contract for home/editor/preview/inline tree renders; inline enforces
the chat-card subset; render tokens carry effect 'read', so render
handlers that mutate fail at the capability gate.
- createColineToolHandler generalized into createColineAppHandler: one
external endpoint ({baseUrl}/coline/app) routes tool.invoke and
render.surface to the defineApp() runtime. 80 sdk tests green (5 new
render tests).
Platform (apps/web):
- lib/apps/dispatch.ts: shared invocation dispatch for both kinds and
both execution models, extracted from app-tools; realtime endpoint
generalized from /apps/tools/execute to /apps/invoke with a bootstrap
that dispatches tools AND surface renders.
- App drives (plan §9.1): drive_kind enum gains 'app',
drives.app_install_id with partial unique index (migration 0225
applied to coline-dev); lazy provisioning; drives.getAppDrive
capability; files.create defaults to the app drive when drives.app is
granted. Drive kind unions widened (app drives evaluate with
shared-drive semantics; sort rank personal → shared → app).
- Preview registry (lib/apps/preview.ts): fileId → owning install →
declared surface → render dispatch, viewer-permission enforced,
fallback chain tree → generic type card → media descriptor. Exposed
at GET /api/workspaces/{slug}/files/{fileId}/preview.
Client:
- <FilePreview fileId variant> (components/platform/file-preview/):
inline/card/full over React Query. Adopted by the tree Reference node
(file references in Kairo cards render live previews; lazy import
breaks the module cycle) and the Drive preview dialog (app files
render their registered preview instead of 'Preview not available').
- Tool card registry: the 500-line getToolDisplay switch is now
tool-card-registry.ts with exact-name + prefix entries (faithful
migration; tool-invocation-card.tsx 600 → 221 lines), resolving the
Phase 1 deviation.
- Fixed the preview dialog's pre-existing lint errors (setState in
effect body, component created during render) surfaced by touching
the file.
Verified: sdk 80 tests green; web typecheck fully clean; lib/apps +
agent tests green; drive access test failures confirmed pre-existing on
main; realtime typecheck clean; eslint clean on all touched files.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>4 files changed+347−120