Repository navigation
Commit c25a576
authored
fix(desktop): persist runs and recover question workflows (#428)
## Summary
Make generation and question workflows survive renderer refreshes,
window switches, and temporary detachment without introducing a new
database. The main process now owns durable run/question state, chat
projection, and completion snapshots; the renderer reattaches using
ordered replay and preserves unanswered form drafts.
### Changes
- Persist `runId`/`generationId`, monotonic event sequences, schema
version, and explicit `run_settled` outcomes in per-run JSONL journals.
Commit events before broadcasting; validate cursors and fail closed on
committed corruption while repairing incomplete tails.
- Subscribe before replay, buffer overlapping live events, deduplicate
cursors, recover gaps, and catch up on focus/visibility changes. Support
multiple renderer subscribers without replay-triggered tool execution,
auto-polish, or stale workspace overwrites.
- Persist questions, answers, cancellation/interruption, and
acknowledgement state in `ask-journal.jsonl`. Scope queues and drafts to
the owning request/design; retain input on failed persistence, accept
identical answer retries, and reject conflicting retries.
- Project chat/tool/active-message events idempotently. Committed
delivery and tool results outrank inferred terminal fallbacks; repaired
rows refresh even when replay contains only already-consumed cursors.
- Finalize artifact snapshots in the main process so detached completion
does not depend on the original renderer Promise. Reattached renderers
refresh the latest snapshot without recreating it.
- Preserve the upstream native cancellation and import-ownership
protections; keep generation/workspace ownership until the worker
actually settles, and reject duplicate run IDs.
## Type of change
- [x] Bug fix
- [x] New feature
- [ ] Breaking change
## Context
Follow-up to the continuity work in #425, rebased onto `main` including
the v0.2.2 release updates. This PR contains only the recovery
implementation, regression tests, and a desktop patch changeset.
Behavioral reference: [Open Design run identity, JSONL events, replay,
and restart
handling](https://github.com/nexu-io/open-design/blob/f5707c8cae7b61014c5e91e114b9aa07826df725/apps/daemon/src/runtimes/runs.ts).
Retains CoDesign's existing file/JSONL and session-chat approach rather
than importing the separate logical-task database architecture.
## Recovery contract and limits
- Renderer refresh/detachment can reattach to a still-running
main-process run and pending questions.
- A main-process restart preserves history and marks orphaned
runs/questions **interrupted**. It does **not** resurrect provider
Promises or automatically repeat tools/side effects.
- Question answers are acknowledged only after persistence. Invalid
submissions leave the question available for correction; losing a window
no longer cancels the question by itself.
- Additive IPC fields and versioned journals; no SQLite, new production
dependencies, or retention/deletion policy.
- Very large histories may need future replay pagination and writer
backpressure.
## Validation
Executed locally on Windows with Node 22 and repository-pinned pnpm:
- `pnpm lint` — passed (617 files).
- `pnpm typecheck` — passed for the workspace.
- `pnpm test` — passed for the workspace; desktop **152 test files, 1937
passed / 1 skipped**. Unchanged workspace packages used valid Turbo
cache entries.
- `pnpm --filter @open-codesign/desktop build` — main, preload, and
renderer bundles passed.
- `git diff --check` — passed. Repository commit/push hooks also passed.
Regression coverage includes temporary-filesystem
reopen/torn-write/corruption cases, failed durable answers,
identical/conflicting retries, native cancellation ownership,
replay/live overlap and gaps, multiple subscribers, headless completion
and snapshot persistence, repaired chat authority, stale status
responses, design-scoped drafts, and cancellation/import races.
No paid/live-provider manual Electron reload acceptance run was
performed. No visual redesign or screenshot recording is included;
renderer recovery and import behavior are covered by component tests.
## Checklist
- [x] Checked relevant continuity context and upstream implementation
- [x] `pnpm lint && pnpm typecheck && pnpm test` passes locally
- [x] Added/updated regression tests
- [x] Added a user-visible desktop patch changeset
- [x] Documented recovery boundaries above
- [x] Additive protocol, schema-versioned storage, explicit main-process
ownership
- [x] No new production dependencies or database layer
Signed-off-by: Sun-sunshine06 <Sun-sunshine06@users.noreply.github.com>
Co-authored-by: Sun-sunshine06 <Sun-sunshine06@users.noreply.github.com>1 parent 4284ede commit c25a576
27 files changed
Lines changed: 3938 additions & 349 deletions
File tree
- .changeset
- apps/desktop/src
- main
- ipc
- preload
- renderer/src
- components
- hooks
- store/slices
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
6 | 13 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
25 | 24 | | |
26 | | - | |
27 | 25 | | |
| 26 | + | |
28 | 27 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
33 | 31 | | |
34 | 32 | | |
35 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
37 | 50 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
52 | 70 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
58 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
59 | 98 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
68 | 108 | | |
69 | 109 | | |
70 | 110 | | |
71 | 111 | | |
72 | 112 | | |
73 | 113 | | |
74 | | - | |
| 114 | + | |
75 | 115 | | |
| 116 | + | |
| 117 | + | |
76 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
77 | 126 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 127 | + | |
| 128 | + | |
89 | 129 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
96 | 145 | | |
97 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
98 | 149 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 150 | + | |
104 | 151 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
135 | 159 | | |
136 | 160 | | |
137 | 161 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
144 | 181 | | |
145 | 182 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
150 | 193 | | |
| 194 | + | |
151 | 195 | | |
152 | 196 | | |
153 | 197 | | |
154 | 198 | | |
155 | 199 | | |
156 | 200 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
166 | 207 | | |
167 | 208 | | |
168 | 209 | | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 210 | + | |
| 211 | + | |
175 | 212 | | |
176 | 213 | | |
177 | 214 | | |
178 | 215 | | |
179 | | - | |
| 216 | + | |
180 | 217 | | |
181 | | - | |
182 | 218 | | |
183 | 219 | | |
184 | 220 | | |
185 | | - | |
| 221 | + | |
| 222 | + | |
186 | 223 | | |
187 | 224 | | |
188 | 225 | | |
189 | 226 | | |
190 | | - | |
| 227 | + | |
| 228 | + | |
191 | 229 | | |
192 | 230 | | |
193 | 231 | | |
194 | | - | |
| 232 | + | |
195 | 233 | | |
196 | 234 | | |
197 | | - | |
| 235 | + | |
198 | 236 | | |
199 | 237 | | |
200 | 238 | | |
201 | 239 | | |
202 | 240 | | |
203 | | - | |
204 | 241 | | |
205 | 242 | | |
206 | 243 | | |
| |||
0 commit comments