You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added user-facing documentation for .cmux/init hooks under Workspaces section.
Covers:
- Basic example with setup instructions
- Behavior (runs once, streams output, non-blocking, exit codes)
- Common use cases (deps, builds, codegen, services)
- Output display (banner with status and logs)
- Idempotency considerations
Follows docs/STYLE.md guidelines:
- Assumes technical competence
- Focuses on non-obvious behavior (non-blocking, idempotency)
- Concise and practical examples
- No obvious details
fix: Subscribe to workspace immediately after creation for real-time init events
When a workspace is created, the init hook starts running immediately in
the background. However, the frontend previously waited for React effects
to process the workspace metadata update before subscribing to events.
This created a race condition where early init hook output lines were
emitted before the frontend subscribed, causing them to be dropped at the
WebSocket layer (only subscribed clients receive messages).
Although these events would be replayed when subscription finally happened,
this broke the real-time streaming UX - users saw all output appear at once
in a batch instead of streaming line-by-line.
Fix by calling workspaceStore.addWorkspace() immediately after receiving
the workspace creation response, before React effects run. This ensures
the frontend is subscribed before (or very quickly after) the init hook
starts emitting events, preserving the real-time streaming experience.
Also export getWorkspaceStoreForEagerSubscription() to allow non-React
code to access the singleton store instance for imperative operations.
Init output appears in a banner at the top of the workspace. Click to expand/collapse the log. The banner shows:
41
+
- Script path (`.cmux/init`)
42
+
- Status (running, success, or exit code on failure)
43
+
- Full stdout/stderr output
44
+
45
+
## Idempotency
46
+
47
+
The hook runs every time you create a workspace, even if you delete and recreate with the same name. Make your script idempotent if you're modifying shared state.
0 commit comments