-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(web): stop truncating multi-line plugin transcript messages #1185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abhay-codes07
wants to merge
1
commit into
supermemoryai:main
Choose a base branch
from
abhay-codes07:fix/plugin-transcript-multiline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { describe, expect, it } from "bun:test" | ||
| import { parsePluginDocument } from "./plugin-document" | ||
|
|
||
| type PluginDocumentInput = Parameters<typeof parsePluginDocument>[0] | ||
|
|
||
| function makeCodexSessionDocument(content: string): PluginDocumentInput { | ||
| return { | ||
| id: "doc_1", | ||
| title: "Codex session", | ||
| content, | ||
| metadata: { sm_source: "codex" }, | ||
| memoryEntries: [], | ||
| } as unknown as PluginDocumentInput | ||
| } | ||
|
|
||
| describe("parsePluginDocument — session transcripts", () => { | ||
| it("keeps multi-line message bodies intact", () => { | ||
| const parsed = parsePluginDocument( | ||
| makeCodexSessionDocument( | ||
| [ | ||
| "[Session abc-123]", | ||
| "1. [user] Hello there", | ||
| "Here is more context on line two", | ||
| "2. [assistant] Sure!", | ||
| "Second line of the reply", | ||
| ].join("\n"), | ||
| ), | ||
| ) | ||
|
|
||
| expect(parsed).not.toBeNull() | ||
| expect(parsed?.kind).toBe("codex-session") | ||
| expect(parsed?.messages).toHaveLength(2) | ||
| expect(parsed?.messages[0]?.text).toBe( | ||
| "Hello there\nHere is more context on line two", | ||
| ) | ||
| expect(parsed?.messages[1]?.text).toBe("Sure!\nSecond line of the reply") | ||
| }) | ||
|
|
||
| it("surfaces memory id artifacts from continuation lines", () => { | ||
| const parsed = parsePluginDocument( | ||
| makeCodexSessionDocument( | ||
| [ | ||
| "[Session abc-123]", | ||
| "1. [user] Remember my editor is Neovim", | ||
| "memory id: mem_456", | ||
| "2. [assistant] Saved it.", | ||
| ].join("\n"), | ||
| ), | ||
| ) | ||
|
|
||
| expect(parsed?.messages[0]?.text).toBe("Remember my editor is Neovim") | ||
| expect(parsed?.artifacts).toContainEqual({ | ||
| label: "Memory ID", | ||
| value: "mem_456", | ||
| }) | ||
| }) | ||
|
|
||
| it("normalizes literal \\n escapes before splitting messages", () => { | ||
| const parsed = parsePluginDocument( | ||
| makeCodexSessionDocument( | ||
| "[Session abc-123]\\n1. [user] First line\\nSecond line\\n2. [assistant] Reply", | ||
| ), | ||
| ) | ||
|
|
||
| expect(parsed?.messages).toHaveLength(2) | ||
| expect(parsed?.messages[0]?.text).toBe("First line\nSecond line") | ||
| expect(parsed?.messages[1]?.text).toBe("Reply") | ||
| }) | ||
|
|
||
| it("parses single-line messages as before", () => { | ||
| const parsed = parsePluginDocument( | ||
| makeCodexSessionDocument( | ||
| ["[Session abc-123]", "1. [user] Hi", "2. [assistant] Hello!"].join( | ||
| "\n", | ||
| ), | ||
| ), | ||
| ) | ||
|
|
||
| expect(parsed?.messages).toHaveLength(2) | ||
| expect(parsed?.messages[0]?.text).toBe("Hi") | ||
| expect(parsed?.messages[1]?.text).toBe("Hello!") | ||
| expect(parsed?.summary).toBe( | ||
| "1 user message and 1 assistant message captured from Codex.", | ||
| ) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
makeCodexSessionDocumentuses 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 theas unknown as PluginDocumentInputassertion.Spotted by Graphite (based on custom rule: TypeScript style guide (Google))

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