fix(chat): show memory source fallbacks#1167
Conversation
|
Claude finished @Dhravya's task in 1m 41s —— View job PR Review: Memory Source Fallbacks
Overview: Adds fallback source attribution chips when memory tool outputs exist but the model doesn't include inline Issues found: None — this looks good to ship. The implementation is clean:
Score: 10/10 |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-mcp | 865962a | Jun 27 2026, 04:55 AM |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6798b56. Configure here.
| [messageText, allowedSourceIds], | ||
| ) | ||
| const showMemorySourcesFallback = | ||
| citationIndex.size > 0 && !hasInlineSourceAnnotations |
There was a problem hiding this comment.
Fallback gate ignores text runs
High Severity
hasInlineSourceAnnotations parses all text parts as one space-joined string, while the answer UI parses each contiguous text run separately and stops at tool and other non-text parts. Response markup split across those boundaries can look fully parsed in the gate check but produce no citation links in any rendered run, so showMemorySourcesFallback stays off and memory sources vanish despite a populated citationIndex.
Reviewed by Cursor Bugbot for commit 6798b56. Configure here.
There was a problem hiding this comment.
Overview: Adds fallback source attribution chips when memory tool outputs exist but the model doesn't include inline <response source="..."> markup.
Issues found: None — this looks good to ship.
The implementation is clean:
- URL handling properly sanitized via
safeExternalUrlbefore rendering in href attributes - Source IDs validated against
SAFE_SOURCE_ID_REbefore being used in anchor links - Good separation of concerns with the extracted
getCitationDisplayhelper andhasDisplayMetadatacheck - The
buildCitationIndexfallback to match byresult.idwhencitationIdis absent handles the edge case described in the PR - The
hasInlineSourceAnnotationsdetection logic correctly checks for transformed#sm-source:links in the parsed output, ensuring fallback chips only appear when needed - Test coverage added for the new code paths (18/18 tests passing)
Score: 10/10
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
supermemory-app | 865962a | Commit Preview URL Branch Preview URL |
Jun 27 2026, 04:56 AM |
|
Cursor Bugbot finding addressed in 865962a. The fallback gate now uses the same contiguous text/source-url run helper as AgentMessage rendering, so response markup split across a tool boundary no longer suppresses fallback sources. Contiguous text -> source-url -> text runs still count as renderable inline citation coverage. Verification:
Attached Images and Videos [supermemory-bugbot-source-run-test.log] [supermemory-bugbot-source-run-biome.log] [supermemory-bugbot-source-run-build.log] 🎥 View recording: source-annotation-agent-message-local-backend.webm |





Chat answers now show deterministic memory/document source attribution when visible memory tool results exist, even if the model skips inline
<response source="...">markup. Inline citations still render when present, and the fallback gate now checks the exact same contiguous rendered text/source-url runs asAgentMessage, so split markup across tool boundaries cannot accidentally suppress fallback sources.Changes
memoryId,kind,content) from structured memory tool outputs.sourceIdsmatchresults[].ideven ifresults[].citationIdis omitted.Memory, while document-backed citations with metadata do not temporarily show the genericMemorylabel.Sourceschips when memory tool outputs provide citation targets and the answer has no valid inline source annotations.text/source-urlrun assembly in source annotation helpers and reuse it for both rendering and fallback suppression.Testing
cd /code/supermemoryai/supermemory && PATH="$HOME/.bun/bin:$PATH" bun test apps/web/lib/chat-memory-tools.test.ts apps/web/lib/source-annotations.test.tscd /code/supermemoryai/supermemory && ./node_modules/.bin/biome ci apps/web/lib/chat-memory-tools.ts apps/web/lib/chat-memory-tools.test.ts apps/web/lib/source-annotations.ts apps/web/lib/source-annotations.test.ts apps/web/components/chat/message/agent-message.tsxcd /code/supermemoryai/supermemory && ./node_modules/.bin/biome ci apps/web/lib/chat-memory-tools.ts apps/web/lib/chat-memory-tools.test.ts apps/web/components/chat/message/agent-message.tsxcd /code/supermemoryai/supermemory && git diff --checkcd /code/supermemoryai/supermemory && ./node_modules/.bin/biome ci --changed --since=origin/maincd /code/supermemoryai/supermemory/apps/web && NODE_ENV=production PATH="$HOME/.bun/bin:$PATH" bun run buildcd /code/supermemoryai/supermemory/apps/web && PATH="$HOME/.bun/bin:$PATH" bunx tsc --noEmit --project tsconfig.jsoncomponents/chat/message/agent-message.tsx,lib/chat-memory-tools.ts,lib/chat-memory-tools.test.ts, orlib/source-annotations.ts.Backend-shaped memory tool output was generated with the real backend mapper and rendered through the real frontend
AgentMessagecomponent:Bugbot follow-up browser/UI verification used a local mock chat backend and the real Next.js app route:
Audit-only earlier UI attempts, not pass evidence:
Authenticated live chat E2E is still blocked because no saved browser session exists; the app and preview load to login instead:
Caveats
forgetMemory; current strict typed confirmation is unchanged.Attached Images and Videos
[supermemory-bugbot-source-run-test.log]
[supermemory-memory-source-cards-bun-test.log]
[supermemory-chat-source-related-bun-tests-after-backend-mapped.log]
[supermemory-bugbot-source-run-biome.log]
[supermemory-memory-source-cards-biome.log]
[supermemory-explicit-files-biome-ci-after-backend-mapped.log]
[supermemory-bugbot-postcommit-biome-changed.log]
[supermemory-postcommit-biome-changed.log]
[supermemory-bugbot-source-run-build.log]
[supermemory-web-build-production.log]
[supermemory-web-tsc.log]
[supermemory-web-tsc-noemit.log]
[backend-mapped-memory-tool-output.json]
🎥 View recording: supermemory-chat-backend-mapped-source-flow.webm
[agent-browser-backend-mapped-snapshot.log]
🎥 View recording: source-annotation-agent-message-local-backend.webm
🎥 View recording: source-annotation-agent-message-history-load.webm
🎥 View recording: supermemory-chat-auth-blocked.webm
Media may expire after 12 hours. View in Vorflux Session for permanent access.
Session Details
(aside)to your comment to have me ignore it.