Skip to content

refactor(gateway): remove unused readLastMessagePreviewFromTranscript helper#84427

Merged
odysseus0 merged 1 commit into
openclaw:mainfrom
medns:cleanup/unused-read-last-message-preview
May 21, 2026
Merged

refactor(gateway): remove unused readLastMessagePreviewFromTranscript helper#84427
odysseus0 merged 1 commit into
openclaw:mainfrom
medns:cleanup/unused-read-last-message-preview

Conversation

@medns

@medns medns commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: The helper function readLastMessagePreviewFromTranscript in src/gateway/session-utils.fs.ts (re-exported in src/gateway/session-utils.ts) was unused throughout the gateway codebase. Other files use the more efficient, cached readSessionTitleFieldsFromTranscript (or its async version) to retrieve previews.
  • Solution: Removed readLastMessagePreviewFromTranscript and its export.
  • What changed:
    • Removed the unused readLastMessagePreviewFromTranscript implementation in src/gateway/session-utils.fs.ts.
    • Removed the re-export of readLastMessagePreviewFromTranscript in src/gateway/session-utils.ts.
    • Removed tests and references to readLastMessagePreviewFromTranscript from src/gateway/session-utils.fs.test.ts.
  • What did NOT change (scope boundary): Inner helper methods like readLastMessagePreviewFromOpenTranscript remain unchanged as they are still utilized by other session-utils helpers.

Motivation

Explain why this change should exist now. Link it to the user pain, failure mode, maintainer need, or product goal. If this is purely mechanical, write N/A.

  • Deleting dead code simplifies the codebase, prevents future misuse, and reduces overall maintainer debt.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related #
  • This PR fixes a bug or regression

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Dead/unused readLastMessagePreviewFromTranscript helper function inside session-utils.

  • Real environment tested: Local development environment running Node.js 22.22.0 on Windows 10 Pro with pnpm workspaces.

  • Exact steps or command run after this patch:

    1. Ran the local gateway unit tests to ensure all other transcript helpers function correctly:
      pnpm test src/gateway/session-utils.fs.test.ts --run
    2. Verified that the main OpenClaw CLI builds, boots, and can successfully query session statuses:
      pnpm openclaw status
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):

    1. Running the live pnpm openclaw status command successfully queries the status and outputs without any module or export resolution crashes:
    $ pnpm openclaw status
    OpenClaw status
    
    Overview
    +----------------------+-----------------------------------------------------------------------------------------------+
    | Item                 | Value                                                                                         |
    +----------------------+-----------------------------------------------------------------------------------------------+
    | OS                   | windows 10.0.26200 (x64) · node 22.22.0                                                       |
    | Dashboard            | http://127.0.0.1:18789/                                                                       |
    | Tailscale exposure   | off                                                                                           |
    | Channel              | dev (cleanup/unused-read-last-message-preview)                                                |
    | Git                  | cleanup/unused-read-last-message-preview · @ 82c58741                                         |
    | Update               | git cleanup/unused-read-last-message-preview · ↔ origin/cleanup/unused-read-last-message-     |
    |                      | preview · up to date · fetch failed · npm latest 2026.5.18 (local newer) · deps ok            |
    | Gateway              | local · ws://127.0.0.1:18789 (local loopback) · unreachable (connect ECONNREFUSED 127.0.0.     |
    |                      | 1:18789)                                                                                      |
    | Gateway service      | Scheduled Task not installed                                                                  |
    | Node service         | Scheduled Task not installed                                                                  |
    | Agents               | 1 · no bootstrap files · sessions 1 · default main active 5d ago                              |
    | Memory               | enabled (plugin memory-core) · not checked                                                    |
    | Plugin compatibility | none                                                                                          |
    | Probes               | skipped (use --deep)                                                                          |
    | Events               | none                                                                                          |
    | Tasks                | none                                                                                          |
    | Heartbeat            | 30m (main)                                                                                    |
    | Sessions             | 1 active · default gpt-5.5 (200k ctx) · ~\.openclaw\agents\main\sessions\sessions.json        |
    +----------------------+-----------------------------------------------------------------------------------------------+
    
    1. Terminal output from the Vitest run showing 72 passing tests:
    [test] starting test/vitest/vitest.gateway.config.ts
    
     RUN  v4.1.6 D:/openclaw
    
    
     Test Files  1 passed (1)
          Tests  72 passed (72)
       Start at  11:56:22
       Duration  9.75s (transform 971ms, setup 805ms, import 7.16s, tests 1.24s, environment 0ms)
    
    [test] passed 1 Vitest shard in 26.34s
    
  • Observed result after fix: The pnpm openclaw status command successfully compiled and returned the correct state of the repository under the cleanup/unused-read-last-message-preview branch. The test suite completed successfully and verified all 72 remaining test cases pass without references to the deleted helper.

  • What was not tested: None.

Root Cause (if applicable)

  • Root cause: N/A
  • Missing detection / guardrail: N/A
  • Contributing context (if known): N/A

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
  • Target test or file: src/gateway/session-utils.fs.test.ts
  • Scenario the test should lock in: Ensure remaining session helpers retrieve previews and summary fields exactly as before.
  • Why this is the smallest reliable guardrail: Direct unit testing of the remaining methods.
  • Existing test that already covers this (if any): Yes, the remaining 72 tests in session-utils.fs.test.ts cover these cases.
  • If no new test is added, why not: N/A (We deleted code and tests that were specific to the deleted helper).

User-visible / Behavior Changes

None.

Diagram (if applicable)

N/A

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)

Repro + Verification

Environment

  • OS: win32 10.0.26200
  • Runtime/container: Node.js 22.19.0
  • Model/provider: N/A
  • Integration/channel (if any): N/A
  • Relevant config (redacted): N/A

Steps

  1. Run pnpm test src/gateway/session-utils.fs.test.ts --run

Expected

  • All remaining unit tests pass with no references to the removed helper.

Actual

  • All 72 tests passed successfully.

Evidence

Attach at least one:

  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: Ran local Vitest gateway tests on session-utils.fs to verify 100% success on the remaining active code.
  • Edge cases checked: Double checked that readLastMessagePreviewFromTranscript is not referenced anywhere else in core packages or the plugin-sdk.
  • What you did not verify: None.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)

Risks and Mitigations

None.

Copilot AI review requested due to automatic review settings May 20, 2026 04:01
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M proof: supplied External PR includes structured after-fix real behavior proof. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
The PR deletes the unused gateway readLastMessagePreviewFromTranscript helper, its barrel re-export, and its direct unit tests.

Reproducibility: not applicable. this is a cleanup PR, not a bug report. The source check is high-confidence because the helper has no live call sites outside its export and direct tests on current main.

PR rating
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Summary: Good small cleanup with adequate copied CLI proof and no blocking findings; normal CI and maintainer review remain.

Rank-up moves:

  • none
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Sufficient (live_output): The PR body provides copied after-patch pnpm openclaw status output plus focused gateway unit-test output, which is adequate real behavior proof for this no-user-visible cleanup.

Next step before merge
No repair lane is needed; the open PR is already a focused cleanup with no actionable review finding.

Security
Cleared: The diff only removes gateway helper code, a barrel export, and tests; it does not touch dependencies, CI, secrets, permissions, network calls, or execution surfaces.

Review details

Best possible solution:

Land the bounded deletion after normal CI and maintainer review, keeping the active readSessionTitleFieldsFromTranscript preview path intact.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a cleanup PR, not a bug report. The source check is high-confidence because the helper has no live call sites outside its export and direct tests on current main.

Is this the best way to solve the issue?

Yes: deleting the unused wrapper and barrel export is the narrow maintainable cleanup while preserving the cached readSessionTitleFieldsFromTranscript preview implementation.

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides copied after-patch pnpm openclaw status output plus focused gateway unit-test output, which is adequate real behavior proof for this no-user-visible cleanup.
  • add rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🐚 platinum hermit, patch quality is 🦞 diamond lobster, and Good small cleanup with adequate copied CLI proof and no blocking findings; normal CI and maintainer review remain.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides copied after-patch pnpm openclaw status output plus focused gateway unit-test output, which is adequate real behavior proof for this no-user-visible cleanup.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is a narrow internal gateway cleanup with no user-visible behavior change and limited blast radius.
  • rating: 🐚 platinum hermit: Current PR rating is 🐚 platinum hermit because proof is 🐚 platinum hermit, patch quality is 🦞 diamond lobster, and Good small cleanup with adequate copied CLI proof and no blocking findings; normal CI and maintainer review remain.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides copied after-patch pnpm openclaw status output plus focused gateway unit-test output, which is adequate real behavior proof for this no-user-visible cleanup.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides copied after-patch pnpm openclaw status output plus focused gateway unit-test output, which is adequate real behavior proof for this no-user-visible cleanup.

What I checked:

  • Current main still has the wrapper the PR removes: Current main exports readLastMessagePreviewFromTranscript from src/gateway/session-utils.fs.ts and re-exports it from src/gateway/session-utils.ts; the PR removes exactly those exposed internal symbols plus direct tests. (src/gateway/session-utils.fs.ts:1116, 9eee202a694b)
  • No live source call sites found: Repository search found readLastMessagePreviewFromTranscript only in the current export/barrel and its direct test block, while active session rows read previews through readSessionTitleFieldsFromTranscript. (src/gateway/session-utils.ts:1868, 9eee202a694b)
  • Active preview path remains intact: The still-used readSessionTitleFieldsFromTranscript path calls the private tail reader directly for lastMessagePreview, so deleting the unused public wrapper does not remove the runtime preview implementation. (src/gateway/session-utils.fs.ts:841, 9eee202a694b)
  • History points to recent gateway-session refactor: Blame attributes the cached title-field path, private tail readers, wrapper, and barrel export to commit 28beea9, which is the central current-main history for this cleanup area. (src/gateway/session-utils.fs.ts:790, 28beea9e881c)
  • Package exports do not expose gateway internals as public API: The root package exports public entry points and plugin SDK subpaths, and the inspected export section does not publish src/gateway/session-utils as a supported package subpath. (package.json:97, 9eee202a694b)
  • Contributor proof supplied: The PR body includes copied after-patch output for pnpm openclaw status on Windows and a focused gateway Vitest run showing 72 passing tests for src/gateway/session-utils.fs.test.ts. (82c58741b55d)

Likely related people:

  • Sebastien Tardif: Current blame for the cached title-field helper, private last-message readers, removable wrapper, and barrel export points to the recent gateway/session utility refactor commit. (role: introduced current helper path; confidence: high; commits: 28beea9e881c; files: src/gateway/session-utils.fs.ts, src/gateway/session-utils.ts, src/gateway/session-utils.fs.test.ts)
  • Peter Steinberger: Recent history on the same gateway session utility files includes multiple session-helper and gateway-reader refactors, making this a useful routing candidate for cleanup policy or coverage preferences. (role: recent area contributor; confidence: medium; commits: 28d478dc5232, b3ecabbbb722, a4f16f572c74; files: src/gateway/session-utils.fs.ts, src/gateway/session-utils.ts, src/gateway/session-utils.fs.test.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 9eee202a694b.

Copilot AI 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.

Pull request overview

Removes the unused readLastMessagePreviewFromTranscript helper from the gateway session utilities, along with its barrel export and dedicated unit tests, consolidating transcript preview reads around the existing readSessionTitleFieldsFromTranscript (sync/async) pathways.

Changes:

  • Deleted readLastMessagePreviewFromTranscript from src/gateway/session-utils.fs.ts.
  • Removed the corresponding re-export from src/gateway/session-utils.ts.
  • Removed unit tests and remaining references to the deleted helper from src/gateway/session-utils.fs.test.ts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/gateway/session-utils.ts Drops the re-export of the removed helper to prevent downstream usage.
src/gateway/session-utils.fs.ts Removes the now-unused wrapper function while keeping internal tail-preview helpers used elsewhere.
src/gateway/session-utils.fs.test.ts Deletes tests that only validated the removed helper and trims shared-behavior assertions accordingly.

@medns medns changed the title refactor(gateway): remove unused readLastMessagePreviewFromTranscript helper [AI] refactor(gateway): remove unused readLastMessagePreviewFromTranscript helper May 20, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 💎 rare Cosmic Branchling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 💎 rare.
Trait: guards the happy path.
Image traits: location green-check meadow; accessory release bell; palette amber, ink, and glacier blue; mood patient; pose standing beside its cracked shell; shell paper lantern shell; lighting tiny status-light glow; background small green status lights.
Share on X: post this hatch
Copy: My PR egg hatched a 💎 rare Cosmic Branchling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@medns

medns commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 20, 2026
@odysseus0
odysseus0 force-pushed the cleanup/unused-read-last-message-preview branch from 82c5874 to 7f89a3e Compare May 21, 2026 20:08
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 21, 2026
@odysseus0
odysseus0 force-pushed the cleanup/unused-read-last-message-preview branch from 7f89a3e to 86bce72 Compare May 21, 2026 20:10
@odysseus0
odysseus0 force-pushed the cleanup/unused-read-last-message-preview branch from 86bce72 to 257aab2 Compare May 21, 2026 20:16
@odysseus0
odysseus0 merged commit 9b7e431 into openclaw:main May 21, 2026
21 checks passed
@odysseus0

Copy link
Copy Markdown
Contributor

Merged via squash.

Thanks @medns!

SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
… helper (openclaw#84427)

Merged via squash.

Prepared head SHA: 257aab2
Co-authored-by: medns <[email protected]>
Co-authored-by: odysseus0 <[email protected]>
Reviewed-by: @odysseus0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants