Skip to content

[companion] fix(sessions): find the first user message past injected context - #94

Closed
andrebrait wants to merge 3 commits into
companion/session-first-message-scan-basefrom
fix/session-first-message-scan
Closed

andrebrait wants to merge 3 commits into
companion/session-first-message-scan-basefrom
fix/session-first-message-scan

Conversation

@andrebrait

@andrebrait andrebrait commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Review companion for kahme247#243: same head branch, base pinned to the same upstream/main commit (05fb0a8), so the diff is identical. Bot reviews only; merge happens upstream.

Summary by CodeRabbit

  • Bug Fixes
    • Session listings now continue scanning past extensive injected context to find the first user message, helping ensure its preview is displayed.
    • Malformed user-like entries are skipped, and message previews are limited to 4,096 characters for more manageable listings.

omp writes rules, skills and memory-recall entries before the first user
message, which pushes it past the 4 KiB list-scan prefix. The sidebar then
showed "(no messages)" and auto-name refused with no messages to name until
omp set a title. When the prefix has no user message, scan up to 256 KiB.
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 247ea9da-2423-442f-b2d5-04a8bd537575

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 16c13860-4de8-48cc-953d-a5827f70aa86


📥 Commits

Reviewing files that changed from the base of the PR and between 05fb0a8 and 57b2e32.



📒 Files selected for processing (2)
  • lib/omp/session-files.ts
  • lib/session-reader.test.mjs


Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

Session listing now scans beyond its initial prefix when it finds no first message and the file exceeds 4 KiB. It stops at the first nonempty user message and limits the extracted text to 4 KiB.

Changes

Session listing

Layer / File(s) Summary
Find and limit the first user message
lib/omp/session-files.ts, lib/session-reader.test.mjs
The line reader callback can stop scanning by returning false. When the prefix scan finds no first message in a file larger than 4 KiB, the scanner skips malformed or empty entries and finds the first nonempty user message. The extracted text is limited to 4 KiB. Tests cover long injected prefixes, a malformed line, and a long message.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: kahme247



Merge Risk: ⚪ Minimal · up to 57b2e

The extended scan addresses long injected context, and no actionable merge-blocking risk remains after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: finding the first user message after injected context.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.



✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR





🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@andrebrait

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment
@andrebrait

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T18:29:48.453468Z 08a6929 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@andrebrait

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Pull request base or head changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 8bc41e8f42

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/omp/session-files.ts Outdated
}

function scanFirstUserMessage(filePath: string): string {
const [window, , size] = readTextSlices(filePath, SESSION_FIRST_MESSAGE_SCAN_BYTES, 0);

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 Continue past 256 KiB to find the first user message

When injected rules, skills, or recalled memory exceed 256 KiB, this bounded read never examines the first user entry; the subsequent fallback only checks the original 4 KiB prefix. Such sessions are therefore listed as (no messages), cannot be found by prompt text, and the documented auto-name fallback can incorrectly return session_no_messages_to_name. Scan JSONL entries until the first textual user message is found while bounding only the retained result, rather than the input offset.

AGENTS.md reference: AGENTS.md:L221-L225

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 57b2e32: the scan now streams lines until the first textual user entry, with no fixed read window. forEachFileLineSync stops when its callback returns false. A regression case covers a user entry behind 300 KB of injected context.

Injected context larger than 256 KiB still hid the first user message.
Stream lines until the first textual user entry instead; forEachFileLineSync
now stops when onLine returns false.
@andrebrait

Copy link
Copy Markdown
Owner Author

@codex review

@andrebrait

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 57b2e326d2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…iling

The streaming scan read oversized files whose prefix has no user message,
and a line past the JS string cap threw, so scanSessionInfo dropped the
session and its route returned 404 instead of 413.
@andrebrait

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 08a69290d7

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@andrebrait

Copy link
Copy Markdown
Owner Author

Upstream kahme247#243 merged.

@andrebrait andrebrait closed this Oct 11, 2026
@andrebrait
andrebrait deleted the fix/session-first-message-scan branch October 11, 2026 00:37
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.

1 participant