Repository navigation
Commit e978913
authored
fix(local-webui): replay a period until its chat is saved; keep its opening; message_composer bounds (#563)
* fix(local-webui): replay a period until its chat is saved; no doubled replies; message_composer bounds
The non-blocking findings of the web-1 review (1-3) and the web-2 review (1-2), R5 of the
pre-0.14 polish.
web-1 #1, a replay without its opening turn duplicated the reply:
- chat.ts buffers consecutive text deltas as one event under the last one's id (kiro-cli
sends one per chunk), so MAX_BUFFERED_EVENTS (2000) drops a period's beginning much later.
`bufferedAfter` gives a Last-Event-ID inside a merged run only the text after it.
- useChatStream: a replay whose first message or output comes before any prompt turn cuts
the history with `cutHistory(null)`; cutLocalAtPrompt(null) keeps the messages through the
last user message. Cloud's cut returns undefined for null (unchanged behaviour).
web-1 #2, delivered before saved:
- The stream's end only records `endWritten`; the period is delivered (`markDelivered`) when
the page's save after the stream's end reaches /api/agent/chat with `delivered: <session>`
and `.chat.json` was written (saveChatToDeck now returns whether it wrote). Until then
/api/agent/stream replays it. onSendComplete passes the session id the run streamed.
web-1 #3, a failed /stream settled running tasks:
- resumeLocalAgent rejects unless the answer is SSE or a JSON `{running: false}`; resumeLocal
maps a failure to undefined, so settleStaleTasks runs only on the server's "nothing runs".
web-2 #1, message_composer relayed past the tool's checks:
- compose-run routes only input within the tool's bounds (group >= 1, text 1..10 000 code
points); out-of-bounds input sends nothing, shows the tool's own refusal as an error and
sends no <message_composer_error>.
web-2 #2, finish() read isDropped before dropped() set it:
- finish({dropped: true}): a drop ends the task cancelled, also after the 60-minute timeout.
CHANGELOG [Unreleased] / Fixed: two entries.
Checks run (worktree, this commit's tree):
- web-ui: npx eslint src/ e2e/ --quiet: ok; npx tsc --noEmit: ok; npm test: 111 files /
1350 tests passed; npm run build:cloud: ok; npx playwright test: 28 passed;
en/ja key parity: OK; package-lock.json unchanged
- make lint: ok
- make test: 2813 passed, 18 skipped, 1 failed: tests/test_html_assemble.py::
test_svg_icon_is_inlined_with_prefixed_ids ("asset not found: assets:aws/
Arch_AWS-Lambda_48"), from this machine's installed asset catalog; this commit changes no
Python, test or asset file
- ash scan --mode local --fail-on-findings: exit 0
- New tests fail on the old code (compose-run bounds and drop-after-timeout checked by
stashing compose-run.ts)
* fix(local-webui): keep a period's opening in the replay buffer; route coerced message_composer input as not delivered
Review of 66e51de2 (review.json, CHANGES_REQUESTED), findings 1-4.
1. message_composer input the tool accepts but toolUse does not route (blocker):
messageEnded shows the tool's own result as an error only when the tool refused
(end.status "error" or result.status "error"). Other out-of-bounds input, such as a
numeric-string group the tool coerces and answers "Sent", goes down the not-delivered
path again: an error card and a <message_composer_error>, as on main.
2. A prompt-less replay dropped the saved head of a reply or still duplicated it. Chosen
outcome: chat.ts never drops a period's opening (its events through the first turn,
Period.opening). Past MAX_BUFFERED_EVENTS the oldest event after the opening goes, so a
Local replay always starts with its prompt and the page cuts its history there. A saved
reply or steer is never shown twice. What the buffer dropped is not replayed, so the
reopened chat shows that reply from the oldest part kept. The cutHistory(null) path
(HistoryCut, cutWithoutPrompt, cutLocalAtPrompt(null)) is removed because nothing reaches
it now.
3. Style chat periods were never delivered: a stream that writes the end of a period of a
chat no deck holds (savedDecks empty) delivers it at once, since no page can reopen it.
4. CHANGELOG: names only the empty and over-long text cases as delivered; describes the
buffer outcome.
Tests: compose-run case {group: "1", text: "x"} with a success result asserts the
<message_composer_error>; chat.test pins the opening past the cap; useChatStream test pins
a truncated replay against a saved full reply and a saved steer (no copy, head gone);
acp-process case for a deck-less chat's delivery; the replay-until-saved cases bind a deck.
The three new server-side tests fail on 66e51de2's code.
Checks run (worktree, this commit's tree):
- web-ui: npx eslint src/ e2e/ --quiet: ok; npx tsc --noEmit: ok; npm test: 111 files /
1351 tests passed; npm run build:cloud: ok (after removing a stale gitignored build/dev
from an earlier dev server); npx playwright test: 28 passed; en/ja key parity: OK;
package-lock.json unchanged
- make lint: ok
- make test: 2813 passed, 18 skipped, 1 failed: tests/test_html_assemble.py::
test_svg_icon_is_inlined_with_prefixed_ids ("asset not found: assets:aws/
Arch_AWS-Lambda_48"), from this machine's asset catalog; no Python, test or asset file changed
- ash scan --mode local --fail-on-findings: exit 01 parent 3498291 commit e978913
20 files changed
Lines changed: 462 additions & 92 deletions
File tree
- web-ui/src
- app/api/agent
- chat
- invoke
- stream
- components/chat
- hooks
- lib/local
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | | - | |
| 14 | + | |
11 | 15 | | |
12 | | - | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
146 | 147 | | |
147 | 148 | | |
148 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
149 | 164 | | |
150 | 165 | | |
151 | 166 | | |
| |||
186 | 201 | | |
187 | 202 | | |
188 | 203 | | |
189 | | - | |
| 204 | + | |
190 | 205 | | |
191 | 206 | | |
192 | 207 | | |
193 | 208 | | |
| 209 | + | |
| 210 | + | |
194 | 211 | | |
195 | 212 | | |
196 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
| 178 | + | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
228 | | - | |
| 228 | + | |
| 229 | + | |
229 | 230 | | |
230 | | - | |
231 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
| |||
361 | 372 | | |
362 | 373 | | |
363 | 374 | | |
364 | | - | |
| 375 | + | |
365 | 376 | | |
366 | 377 | | |
367 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
262 | 303 | | |
263 | 304 | | |
264 | 305 | | |
| |||
276 | 317 | | |
277 | 318 | | |
278 | 319 | | |
| 320 | + | |
279 | 321 | | |
280 | 322 | | |
281 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
107 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| |||
669 | 675 | | |
670 | 676 | | |
671 | 677 | | |
672 | | - | |
| 678 | + | |
673 | 679 | | |
674 | 680 | | |
675 | 681 | | |
| |||
726 | 732 | | |
727 | 733 | | |
728 | 734 | | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
735 | 739 | | |
736 | 740 | | |
737 | 741 | | |
| |||
743 | 747 | | |
744 | 748 | | |
745 | 749 | | |
746 | | - | |
| 750 | + | |
747 | 751 | | |
748 | 752 | | |
749 | 753 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
305 | 318 | | |
306 | 319 | | |
307 | 320 | | |
| |||
0 commit comments