Skip to content

fix(web): stop truncating multi-line plugin transcript messages#1185

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/plugin-transcript-multiline
Open

fix(web): stop truncating multi-line plugin transcript messages#1185
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/plugin-transcript-multiline

Conversation

@abhay-codes07

@abhay-codes07 abhay-codes07 commented Jul 2, 2026

Copy link
Copy Markdown

What

Fixes #1184

Multi-line messages in plugin transcript documents (Codex sessions, Amp threads) were being truncated to their first line in the document modal. The message-splitting regex in parseTranscriptMessages is built with the m flag, and its terminating lookahead ended with |$ — under m, $ matches at every line end, so the lazy [\s\S]*? body (written to span lines) stopped at the first newline.

For this input:

1. [user] Hello there
Here is more context on line two
memory id: mem_123
2. [assistant] Sure!
Second line of the reply

the parser produced messages "Hello there" and "Sure!" — the continuation lines landed in no message at all. Knock-on effects:

  • memory id: lines inside a body were dropped before extractArtifacts could surface them, so the Memory ID chip never showed for multi-line turns
  • previews and the user/assistant message counts in the summary were computed from truncated text

This bites on essentially every real transcript, since normalizeContent converts literal \n escapes to real newlines before parsing.

How

One-token change: the |$ alternative in the lookahead becomes |(?![\s\S]) — a true end-of-input assertion that the m flag can't reinterpret. Message bodies now run until the next N. [role] header or the actual end of the transcript.

The neighboring parseClaudeCodeTurns regex also ends with |$ but doesn't use the m flag, so it already behaves correctly and is left untouched.

Testing

  • New apps/web/lib/plugin-document.test.ts (bun:test, same setup as the other lib/*.test.ts files), exercised through the public parsePluginDocument: multi-line bodies preserved, memory-id artifacts extracted from continuation lines, literal \n normalization, and single-line messages unchanged.
  • Verified the tests catch the bug: against the previous regex the three multi-line cases fail, the single-line case passes (behavior-preserving).
  • Full web lib suite passes (18 tests across 3 files); biome check clean; no new tsc errors in the touched files.

cc @MaheshtheDev


Session Details

  • Session: View Session
  • Requested by: Unknown
  • Address comments on this PR. Add (aside) to your comment to have me ignore it.

parseTranscriptMessages builds its regex with the m flag, and the
lookahead that terminates a message body ends with |$. Under m, $
matches at every line end, so the lazy [\s\S]*? body stops at the
first newline: every line of a message after the first was silently
dropped from Codex session and Amp thread documents. Continuation
lines carrying "memory id: ..." were lost too, so extractArtifacts
never surfaced their Memory ID chips, and previews/message counts
were computed from truncated text.

Replace the |$ alternative with (?![\s\S]), a true end-of-input
assertion unaffected by the m flag. The adjacent parseClaudeCodeTurns
regex is fine as-is - it uses $ without the m flag.

Add regression tests through parsePluginDocument covering multi-line
bodies, memory-id artifact extraction from continuation lines,
literal \n normalization, and unchanged single-line behavior. The
multi-line cases fail against the previous regex.

Fixes supermemoryai#1184
Copilot AI review requested due to automatic review settings July 2, 2026 02:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment on lines +7 to +13
return {
id: "doc_1",
title: "Codex session",
content,
metadata: { sm_source: "codex" },
memoryEntries: [],
} as unknown as PluginDocumentInput

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object literal returned from makeCodexSessionDocument uses a type assertion (as unknown as PluginDocumentInput) instead of a type annotation. According to the 'Use type annotations instead of assertions for object literals' rule, you should annotate the return type of the function or the variable directly rather than casting. For example, annotate the function's return type: function makeCodexSessionDocument(content: string): PluginDocumentInput { return { ... }; } and remove the as unknown as PluginDocumentInput assertion.

Spotted by Graphite (based on custom rule: TypeScript style guide (Google))

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@vorflux

vorflux Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Testing

The testing subagent classified this as a parser-only change with no UI, mobile, API, or integration testing required. Focused parser tests and formatting/lint checks passed on PR HEAD 39115527, and the old truncation behavior was reproduced against origin/main before verifying the fixed behavior on origin/pr-1185.

Commands run:

export PATH="$HOME/.bun/bin:$PATH"
bun test apps/web/lib/plugin-document.test.ts

bunx biome check apps/web/lib/plugin-document.ts apps/web/lib/plugin-document.test.ts

Result:

4 pass
0 fail
14 expect() calls
Ran 4 tests across 1 file.
Checked 2 files in 113ms. No fixes applied.

Before, on origin/main, continuation lines were truncated:

[
  "Hello there",
  "Sure!"
]

After, on origin/pr-1185, multi-line transcript message bodies were preserved:

[
  "Hello there\nHere is more context on line two",
  "Sure!\nSecond line of the reply"
]

Verdict

Passed. Focused parser regression tests and biome checks passed, and before/after evidence confirms the transcript truncation bug is fixed.

@vorflux

vorflux Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Reviewed apps/web/lib/plugin-document.ts and apps/web/lib/plugin-document.test.ts for PR #1185, which updates plugin transcript parsing to preserve multi-line message bodies and adds focused parser regressions. The delegated code review found no actionable bugs, security concerns, data-loss risks, missing error handling, breaking changes, or race conditions.

Verdict

Reviewed — no issues found. The change is narrowly scoped and the parser behavior matches the intended transcript preservation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin transcript parser drops every line after the first in multi-line messages

2 participants