test(gateway): consolidate deriveSessionTitle tests into dedicated module#48942
test(gateway): consolidate deriveSessionTitle tests into dedicated module#48942JFWaskin wants to merge 2 commits into
Conversation
Greptile SummaryThis PR extracts Key observations:
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/gateway/session-title.test.ts
Line: 86-96
Comment:
**Misleading test name: "missing" vs. explicitly zero**
The description says `"falls back to sessionId prefix without date when updatedAt missing"`, but `updatedAt` is explicitly set to `0`, not absent (`undefined`). The `SessionEntry` type declares `updatedAt: number` (required), so `undefined` is not a valid value here — the intent is to cover the **falsy-zero** case. Consider renaming for clarity:
```suggestion
test("falls back to sessionId prefix without date when updatedAt is zero", () => {
const entry = {
sessionId: "abcd1234-5678-90ef-ghij-klmnopqrstuv",
updatedAt: 0,
} as SessionEntry;
const result = deriveSessionTitle(entry);
expect(result).toBe("abcd1234");
});
```
(This was also the description in the original test copied from `session-utils.test.ts`, so this is a good opportunity to clean it up.)
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 0605ae3 |
0605ae3 to
ccbe695
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ccbe695ffd
ℹ️ 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".
|
Thanks for the context here. I did a careful shell check against current Close: the central label-preserving derived-title fix is already on current main through #98841, while this older branch’s helper extraction and origin-label fallback are broader stale leftovers rather than necessary remaining work. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this older PR as already covered on Review detailsBest possible solution: Keep the focused current-main label-precedence fix; if maintainers still want helper extraction or origin-label derived-title fallback, open a new targeted PR with a fresh owner decision. Do we have a high-confidence way to reproduce the issue? No against current main: source inspection shows deriveSessionTitle now returns a normalized label before transcript-derived titles, and the session-list path calls that helper when derived titles are requested. Is this the best way to solve the issue? No, this stale branch is no longer the best landing path; the merged focused fix on main solves the central label problem without carrying the older helper extraction and origin-label behavior. Security review: Security review cleared: Cleared: the branch changes gateway TypeScript helper/test files only and adds no dependency, workflow, secret, permission, or code-execution surface. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against f59310a555d7; fix evidence: commit 68e06b9ea148, main fix timestamp 2026-07-03T09:09:31Z. |
ccbe695 to
8a54ac3
Compare
|
Updated the branch against current
GitHub Actions are running on the refreshed head. |
8a54ac3 to
07ba03d
Compare
|
Applied the review suggestion by renaming the zero timestamp case to describe the actual I also rebased the branch onto current Validation:
|
|
Follow-up status:
I’m keeping this PR scoped to session-title derivation and will not expand it into the unrelated auto-reply ACP failure unless maintainers request that explicitly. |
|
Ready for maintainer review/merge. Status recap against current HEAD
Precedence at HEAD: displayName → subject → explicit label → firstUserMessage → origin.label → sessionId prefix. @codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
This PR fixes an issue where heartbeat polls could overwrite explicit user-labeled session titles with transcript-derived titles like
"heartbeat".Changes
deriveSessionTitletosession-title.tswith a dedicated test module.origin.labelbehindfirstUserMessageso unlabeled inbound DMs can still use transcript-derived titles.session-utils.tsas a compatibility re-export site.updatedAt: 0input.Title precedence
displayNamesubjectentry.labelfirstUserMessage(truncated)entry.origin?.labelsessionIdprefix fallbackReal behavior proof
Behavior or issue addressed: explicit session labels should survive heartbeat-style transcript summaries, while auto-populated origin labels should not override a real first user message.
Real environment tested: local OpenClaw checkout on this branch after rebasing onto current
main.Exact steps or command run after this patch:
Evidence after fix:
{ "explicitLabelBeatsHeartbeat": "My App - Dashboard", "transcriptBeatsAutoOriginLabel": "Need help with deployment", "originLabelFallbackWithoutTranscript": "Discord: Engineering", "zeroUpdatedAtFallback": "abcd1234" }Observed result after fix: explicit labels win over heartbeat transcript text; transcript text wins over auto-populated origin labels; origin labels still act as fallback when there is no transcript; zero
updatedAtkeeps the session-id-only fallback.What was not tested: full gateway UI rendering was not manually opened; this proof covers the extracted title derivation behavior directly.
Validation
pnpm test src/gateway/session-title.test.ts src/gateway/session-utils.test.tsgit diff --check upstream/main...HEAD