Skip to content

fix(gateway): limit session row enrichment#72978

Closed
yeager wants to merge 2 commits intoopenclaw:mainfrom
yeager:fix/session-row-enrichment-limit
Closed

fix(gateway): limit session row enrichment#72978
yeager wants to merge 2 commits intoopenclaw:mainfrom
yeager:fix/session-row-enrichment-limit

Conversation

@yeager
Copy link
Copy Markdown

@yeager yeager commented Apr 27, 2026

Summary

  • avoid building enriched session rows before sessions.list filtering/sorting/limit is applied
  • avoid cloning session stores in the gateway combined-store read path
  • add a regression test proving transcript-backed enrichment is not run for rows outside the requested limit

Testing

  • pnpm exec vitest run --config test/vitest/vitest.gateway.config.ts src/gateway/session-utils.subagent.test.ts
  • pnpm build
  • pnpm ui:build

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Apr 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR defers buildGatewaySessionRow (the expensive transcript-backed enrichment step) until after filtering, sorting, and limiting have been applied, and avoids cloning session store entries in the gateway combined-store read path. The structural change is sound and the regression test for limit-gated enrichment is well-constructed.

  • Search regression: the search filter now operates on raw entry fields. For sessions whose displayName is undefined in the store but would be computed from entry.channel via buildGroupDisplayName, entry?.displayName resolves to undefined — these sessions will silently disappear from search results.

Confidence Score: 3/5

Safe to merge for the common case, but introduces a silent behavioral regression for channel-based sessions searched by display name.

One P1 finding: the search filter now uses raw entry.displayName instead of the computed value from buildGroupDisplayName, silently breaking name-based search for channel (messaging integration) sessions. The optimization itself and the clone-false change are correct.

src/gateway/session-utils.ts — specifically the search filter block around line 1588.

Comments Outside Diff (1)

  1. src/gateway/session-utils.ts, line 1588-1593 (link)

    P1 Search misses channel-derived displayName

    The search filter now runs on raw entry fields, but buildGatewaySessionRow can compute displayName from the session's channel property via buildGroupDisplayName(...) when entry.displayName is undefined. Any session whose display name is derived from the channel (e.g. Slack/Telegram messaging integrations) will no longer appear in search results when the stored entry.displayName is absent — entry?.displayName resolves to undefined while s.displayName in the old path would have held the computed value.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/gateway/session-utils.ts
    Line: 1588-1593
    
    Comment:
    **Search misses channel-derived `displayName`**
    
    The `search` filter now runs on raw `entry` fields, but `buildGatewaySessionRow` can compute `displayName` from the session's `channel` property via `buildGroupDisplayName(...)` when `entry.displayName` is `undefined`. Any session whose display name is derived from the channel (e.g. Slack/Telegram messaging integrations) will no longer appear in search results when the stored `entry.displayName` is absent — `entry?.displayName` resolves to `undefined` while `s.displayName` in the old path would have held the computed value.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/gateway/session-utils.ts
Line: 1588-1593

Comment:
**Search misses channel-derived `displayName`**

The `search` filter now runs on raw `entry` fields, but `buildGatewaySessionRow` can compute `displayName` from the session's `channel` property via `buildGroupDisplayName(...)` when `entry.displayName` is `undefined`. Any session whose display name is derived from the channel (e.g. Slack/Telegram messaging integrations) will no longer appear in search results when the stored `entry.displayName` is absent — `entry?.displayName` resolves to `undefined` while `s.displayName` in the old path would have held the computed value.

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

Reviews (1): Last reviewed commit: "fix(gateway): limit session row enrichme..." | Re-trigger Greptile

@yeager
Copy link
Copy Markdown
Author

yeager commented Apr 27, 2026

Addressed the review: search now uses a lightweight display-name resolver that mirrors the channel-derived buildGroupDisplayName(...) fallback without doing full row enrichment, and I added a regression test for matching slack:g-general before enrichment. Local checks: pnpm exec vitest run --config test/vitest/vitest.gateway.config.ts src/gateway/session-utils.subagent.test.ts (23 passed) and pnpm build.

@steipete
Copy link
Copy Markdown
Contributor

Thanks, this was the right direction. I landed the session-list enrichment optimization on main in 9402bca, including the lightweight channel-derived display-name search fix and regression coverage.

I also landed the related trajectory sidecar cleanup from #73000 separately in a2b84e9.

Verification:

  • pnpm test src/gateway/session-utils.subagent.test.ts src/config/sessions/artifacts.test.ts src/config/sessions/disk-budget.test.ts src/config/sessions/store.pruning.integration.test.ts src/trajectory/cleanup.test.ts
  • pnpm check:changed

Closing this PR as superseded by the maintainer-landed commits, with changelog credit preserved. Thanks again.

@steipete steipete closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants