Commit 6a15b1f
committed
fix(daemon): keep stripping title markers in the post-close remainder of one delta
mrcfps's non-blocking thread on #6342 round-2 review (apps/daemon/src/title-marker.ts L97,
2026-08-02) noted that the previous implementation did
emitTitle(buffer.slice(titleStart, closeIndex));
buffer = buffer.slice(closeIndex + TITLE_CLOSE_TAG.length);
visible += buffer;
buffer = '';
right after the first close tag, which forwarded the post-close remainder to
`visible` without scanning it. Stream delta boundaries are transport-dependent,
so identical model output could leak a raw `<od-title>Two</od-title>` depending
on adapter chunking — breaking the "scanner remains active" invariant this PR
introduced in the comment two lines above.
Concretely, one call with `<od-title>One</od-title>A<od-title>Two</od-title>B`
returned `A<od-title>Two</od-title>B`, whereas splitting the same bytes into
two `strip()` calls removed both markers.
Fix: drop the `visible += buffer; buffer = '';` flush and `continue` the
while loop instead, so the post-close remainder re-enters the same
single-marker scanner. Multiple markers in one delta are now stripped in
the same pass; `emitted` still de-dupes title events across the run.
Test: `apps/daemon/tests/title-marker.test.ts` gains a regression
`title marker stripper strips every marker inside one delta (post-close
remainder keeps scanning)` that asserts `<od-title>One</od-title>A<od-title>Two</od-title>B`
returns `AB` and only `One` is emitted as a title; no marker remains in
the visible output or in the post-flush leftover.
7/7 tests pass locally:
pnpm --filter @open-design/daemon exec vitest run tests/title-marker.test.ts
Signed-off-by: xxiaoxiong <2482929840@qq.com>1 parent 7b9bc7a commit 6a15b1f
2 files changed
Lines changed: 32 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
0 commit comments