Repository navigation
fix(discord): propagate blockquote context across chunk boundaries - #63412
extrasmall0 wants to merge 4 commits into
Conversation
Greptile SummaryThis PR introduces However, the unconditional Confidence Score: 4/5Safe to merge after addressing the line-limit flush regression; no security or data concerns. The character-split fix is correct, but the unconditional re-seeding in flush() introduces an empty blockquote line artefact for every maxLines-triggered split — a verifiable regression on the changed code path. No tests were added to catch either the original bug or this new edge case. extensions/discord/src/chunk.ts — specifically the flush() re-seeding block (lines 154-159) and the absence of a companion chunk.test.ts.
|
| // Re-open blockquote context on next chunk so Discord keeps rendering | ||
| // continuation lines inside the quote block. | ||
| if (openBlockquote && !openFence) { | ||
| current = openBlockquote; | ||
| currentLines = 1; | ||
| } |
There was a problem hiding this comment.
Extra empty blockquote line inserted on line-limit splits
When flush() fires because adding the next full line would exceed maxLines (rather than maxChars mid-line), current is seeded to "> " and then the next line (which already carries its own > prefix) is appended with a "\n" delimiter — producing "> \n> actual content". Discord renders that leading > as a separate, visually empty blockquote paragraph before the real content.
The re-seeding is only necessary for character-split continuations (isLineContinuation = true), where the tail segment has no > of its own. For line-boundary splits every continuation line already carries the correct prefix, so re-seeding just adds an artefact.
One way to scope the fix to the case that needs it:
// Only re-seed when the split happens mid-line (character overrun);
// line-boundary splits naturally carry their own > prefix.
if (openBlockquote && !openFence && isLineContinuation) {
current = openBlockquote;
currentLines = 1;
}This would require threading an isLineContinuation flag into flush() (or inlining the re-seed after the call). The current unconditional seeding is a regression for the maxLines-triggered split path.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/discord/src/chunk.ts
Line: 154-159
Comment:
**Extra empty blockquote line inserted on line-limit splits**
When `flush()` fires because adding the next full line would exceed `maxLines` (rather than `maxChars` mid-line), `current` is seeded to `"> "` and then the next line (which already carries its own `>` prefix) is appended with a `"\n"` delimiter — producing `"> \n> actual content"`. Discord renders that leading `> ` as a separate, visually empty blockquote paragraph before the real content.
The re-seeding is only necessary for *character-split* continuations (`isLineContinuation = true`), where the tail segment has no `>` of its own. For line-boundary splits every continuation line already carries the correct prefix, so re-seeding just adds an artefact.
One way to scope the fix to the case that needs it:
```ts
// Only re-seed when the split happens mid-line (character overrun);
// line-boundary splits naturally carry their own > prefix.
if (openBlockquote && !openFence && isLineContinuation) {
current = openBlockquote;
currentLines = 1;
}
```
This would require threading an `isLineContinuation` flag into `flush()` (or inlining the re-seed after the call). The current unconditional seeding is a regression for the `maxLines`-triggered split path.
How can I resolve this? If you propose a fix, please make it concise.| @@ -0,0 +1,302 @@ | |||
| import { chunkMarkdownTextWithMode, type ChunkMode } from "openclaw/plugin-sdk/reply-chunking"; | |||
There was a problem hiding this comment.
No tests for the new chunking logic
chunk.ts is a new file with non-trivial state-machine logic (fenced code blocks, blockquote tracking, long-line splitting, italics rebalancing), but no chunk.test.ts was added. The PR description lists specific cases that should be covered (split within a > blockquote, nested >>, unchanged non-blockquote content). Given the repo's Vitest + V8 coverage threshold of 70%, adding at least the described table-driven cases would prevent future regressions.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/discord/src/chunk.ts
Line: 1
Comment:
**No tests for the new chunking logic**
`chunk.ts` is a new file with non-trivial state-machine logic (fenced code blocks, blockquote tracking, long-line splitting, italics rebalancing), but no `chunk.test.ts` was added. The PR description lists specific cases that should be covered (split within a `>` blockquote, nested `>>`, unchanged non-blockquote content). Given the repo's Vitest + V8 coverage threshold of 70%, adding at least the described table-driven cases would prevent future regressions.
How can I resolve this? If you propose a fix, please make it concise.|
Follow-up after rechecking the current diff: this is still a narrow Discord chunking fix. The branch keeps blockquote context only for continuation splits where a long quoted line is cut mid-line, and it avoids re-seeding quote state on normal line-boundary flushes, which was the regression Greptile called out earlier. The current patch is focused on preserving quoted rendering across chunk boundaries without introducing the empty quoted paragraph artifact. If there is a preferred edge case to cover further, I can tighten it quickly. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the focused Discord chunking fix is still useful, but the current branch introduces private core imports across the extension boundary and still lacks after-fix real Discord rendering proof. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. Current main routes Discord sends through Is this the best way to solve the issue? No, not yet. The blockquote algorithm and regression tests are the right narrow repair, but the branch should keep public plugin SDK imports and provide real Discord rendering proof before merge. Security review: Security review cleared: The diff is limited to Discord string chunking, focused tests, and changelog text; no concrete security or supply-chain concern was found. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a04566da11ce. |
|
Rebased this onto current Current head still only does three things:
I reran If maintainers want this to clear the proof gate, I can follow the preferred artifact format for a real Discord rendering check next. |
Keep blockquote prefixes on character-split Discord chunks without re-seeding quote state on normal line-limit flushes, and cover both paths with focused regression tests. Signed-off-by: extrasmall0 <[email protected]>
def2920 to
19e2a41
Compare
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
Signed-off-by: extrasmall0 <[email protected]>
Signed-off-by: sxu75374 <[email protected]>
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Fixes #63409
When
chunkDiscordText()flushed a chunk in the middle of a blockquote, the next chunk started without the leading>prefix. Discord renders each message independently, so continuation lines appeared as plain text outside the quote block.Root cause
The chunker already tracks fenced code block state (
openFence) and re-seeds the next chunk with the opening fence line on flush. The same treatment was never applied to blockquote prefixes.Fix
Track the current blockquote prefix (
openBlockquote) using the same pattern:A
BLOCKQUOTE_REhelper extracts the prefix including nested levels (>,>>, etc.). The prefix is updated on each line and cleared when a non-blockquote line is encountered.Real behavior proof
A minimal reproduction is a long Discord quote whose single quoted line is forced to split across two outgoing messages.
Before this patch, the split output looks like:
Discord renders
chunk 2as plain text because each message is interpreted independently and the continuation no longer starts with>.With this patch, the split output becomes:
So the continuation remains inside the quote block after the boundary. The same prefix carry-over also preserves nested quotes like
>>, while fenced-code behavior stays on the existingopenFencepath.Behaviour
>blockquote split at chunk boundary>>blockquote split at boundary