Skip to content

fix(qmd): include archived session transcripts in file listing#30273

Closed
pushkarsingh32 wants to merge 3 commits into
openclaw:mainfrom
pushkarsingh32:fix/qmd-session-exporter-include-archived
Closed

fix(qmd): include archived session transcripts in file listing#30273
pushkarsingh32 wants to merge 3 commits into
openclaw:mainfrom
pushkarsingh32:fix/qmd-session-exporter-include-archived

Conversation

@pushkarsingh32

Copy link
Copy Markdown
Contributor

Summary

  • Fixes listSessionFilesForAgent() excluding reset and deleted session transcripts from QMD indexing

Root cause: The file filter used .endsWith(".jsonl") which excluded archived files with suffixes like .jsonl.reset.2026-02-16T22-26-33.000Z and .jsonl.deleted.2026-02-16T22-26-33.000Z. On setups with daily session resets, most conversation history became unsearchable via memory_search.

Fix: Broaden the filter to also match filenames containing .jsonl. so archived transcripts are included.

Changes

  • src/memory/session-files.ts: Update filter to include .jsonl.* archived files

Test plan

  • Existing tests pass (session-files.test.ts — 3/3, artifacts.test.ts — 3/3)
  • Configure session.reset.mode: "daily" and verify archived sessions appear in memory_search results after reset

Fixes #30220

listSessionFilesForAgent() filtered with .endsWith(".jsonl") which
excluded reset (.jsonl.reset.*) and deleted (.jsonl.deleted.*) session
transcripts. On setups with daily session resets, this made most
conversation history unsearchable via memory_search.

Broaden the filter to also match files containing ".jsonl." so archived
transcripts are included in QMD indexing.

Fixes openclaw#30220

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1229796061

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/memory/session-files.ts Outdated
.filter((entry) => entry.isFile())
.map((entry) => entry.name)
.filter((name) => name.endsWith(".jsonl"))
.filter((name) => name.endsWith(".jsonl") || name.includes(".jsonl."))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict session filter to actual transcript artifacts

The new predicate name.includes(".jsonl.") also matches lock files like *.jsonl.lock, which are created in the same sessions directory (src/agents/session-write-lock.ts:429). That means listSessionFilesForAgent() now returns non-transcript artifacts, so full sync/export paths will treat lock files as session inputs and generate empty session records/markdown outputs, adding index churn and noisy artifacts. Please narrow this to known transcript/archive filename patterns instead of any .jsonl. substring.

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where listSessionFilesForAgent() silently excluded archived session transcripts (.jsonl.reset.*, .jsonl.deleted.*) from QMD memory indexing, making conversation history from daily-reset setups unsearchable via memory_search. The fix is a minimal, well-targeted one-line change that broadens the filename filter.

  • The fix (name.endsWith(".jsonl") || name.includes(".jsonl.")) correctly captures both live and archived transcript files without risking inclusion of unrelated files, since the function already operates on a purpose-specific session transcripts directory.
  • The buildSessionEntry parser gracefully handles unexpected file content by returning null, so any incidental false-positive matches would be silently skipped rather than causing errors.
  • listSessionFilesForAgent has no unit tests; the new filter branch is not covered by the automated test suite, which is the only notable gap in this change.

Confidence Score: 4/5

  • Safe to merge — the fix is minimal, logically correct, and well-contained within a scoped directory.
  • The one-line change correctly addresses the stated root cause, the broader filter cannot inadvertently include unrelated files (operates in a session-specific directory), and any unexpected files are safely handled by the null-returning parser. Score is 4 rather than 5 only because listSessionFilesForAgent lacks unit test coverage for both old and new behavior, leaving the fix manually-verified only.
  • No files require special attention beyond the noted test coverage gap in src/memory/session-files.ts.

Last reviewed commit: 1229796

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/memory/session-files.ts Outdated
.filter((entry) => entry.isFile())
.map((entry) => entry.name)
.filter((name) => name.endsWith(".jsonl"))
.filter((name) => name.endsWith(".jsonl") || name.includes(".jsonl."))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No test coverage for the new filter behavior

The existing test suite covers buildSessionEntry but there are no tests for listSessionFilesForAgent — neither before nor after this change. The PR description marks the manual reset-mode verification step as unchecked, which means the new name.includes(".jsonl.") branch is untested.

Consider adding a unit test that creates mock files with archived names (e.g. session.jsonl.reset.2026-02-16T22-26-33.000Z) in a temp directory and asserts they are returned by listSessionFilesForAgent, similar to how buildSessionEntry is tested in session-files.test.ts.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/memory/session-files.ts
Line: 28

Comment:
**No test coverage for the new filter behavior**

The existing test suite covers `buildSessionEntry` but there are no tests for `listSessionFilesForAgent` — neither before nor after this change. The PR description marks the manual reset-mode verification step as unchecked, which means the new `name.includes(".jsonl.")` branch is untested.

Consider adding a unit test that creates mock files with archived names (e.g. `session.jsonl.reset.2026-02-16T22-26-33.000Z`) in a temp directory and asserts they are returned by `listSessionFilesForAgent`, similar to how `buildSessionEntry` is tested in `session-files.test.ts`.

How can I resolve this? If you propose a fix, please make it concise.

Address review feedback: the previous .includes(".jsonl.") filter
would match non-transcript files like .jsonl.lock. Use the existing
isPrimarySessionTranscriptFileName and isSessionArchiveArtifactName
helpers from artifacts.ts for precise filtering.

Add unit test for listSessionFilesForAgent verifying that primary,
reset, and deleted session files are included while lock files,
sessions.json, and unrelated files are excluded.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37f5eb487d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/memory/session-files.ts Outdated
.map((entry) => entry.name)
.filter((name) => name.endsWith(".jsonl"))
.filter(
(name) => isPrimarySessionTranscriptFileName(name) || isSessionArchiveArtifactName(name),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict archive filter to transcript filenames

listSessionFilesForAgent() now accepts any isSessionArchiveArtifactName(name), but that helper explicitly matches legacy sessions.json.bak.<ts> files (src/config/sessions/artifacts.ts), and those backups are created in the same sessions directory by rotateSessionFile() (src/config/sessions/store.ts). Because buildSessionEntry() then parses them as if they were JSONL transcripts, they get indexed/exported as empty session artifacts, creating noisy memory rows/markdown files whenever store rotation happens. Limit the archive branch to JSONL transcript archives only (for example, *.jsonl.<reason>.<timestamp>).

Useful? React with 👍 / 👎.

Address review: isSessionArchiveArtifactName also matches legacy
sessions.json.bak.* store backups which are not JSONL transcripts.
Replace with a focused regex that only matches .jsonl.{reset,deleted,bak}
archives with ISO timestamps. Update test to verify sessions.json.bak.*
is excluded.
@vincentkoc

Copy link
Copy Markdown
Member

Thanks for the fix here.

Closing this as superseded by #57446, which ports the archived-session export fix onto the current packages/memory-host-sdk path on top of latest main.

Your diagnosis was right: the suffix-only *.jsonl filter was the bug.

@vincentkoc vincentkoc closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: QMD session exporter ignores reset/deleted session transcripts (.jsonl.reset.*, .jsonl.deleted.*)

2 participants