Skip to content

fix(sessions): migrate session naming to canonical title - #95182

Closed
jason-allen-oneal wants to merge 26 commits into
openclaw:mainfrom
jason-allen-oneal:fix/session-title-contract
Closed

jason-allen-oneal wants to merge 26 commits into
openclaw:mainfrom
jason-allen-oneal:fix/session-title-contract

Conversation

@jason-allen-oneal

@jason-allen-oneal jason-allen-oneal commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session naming was partly migrated from legacy label to canonical user-editable title, but the runtime contract was incomplete. New gateway schemas accepted title while sessions.create dropped it, sessions.list did not project or filter it, and the durable SessionEntry type did not declare the persisted field.

Additionally, two regressions existed in the patch path:

  1. sessions.patch({ label: null }) and sessions.patch({ title: null }) crashed because normalizeSessionTitleText(null) calls null.trim() before the null-clear branch.
  2. Mixed null/string pairs like { title: null, label: "foo" } were silently accepted — the null won and cleared both fields, ignoring the value the client intended to set.

Why This Change Was Made

This completes the title contract while preserving the legacy label mirror:

  • sessions.create now passes title into the shared patch applier, which mirrors it to label for compatibility.
  • SessionEntry now declares title?: string as durable session metadata.
  • Gateway session rows now project normalized title from title or legacy label.
  • sessions.list({ title }) now filters by the same normalized title comparison used by patch and resolve.
  • Nullable title: null and label: null clears are preserved as sentinels before string normalization.
  • Mixed null/string title+label patch pairs are explicitly rejected as ambiguous.
  • /name --clear documented in slash-commands.md.
  • Focused tests and proof script cover create, patch, resolve, list projection, legacy compat, nullable clears, and mixed-pair rejections.

User Impact

Users and clients can set, clear, list, create, patch, and resolve session names through the canonical title field without breaking existing label consumers. /name --clear removes the session name. Legacy label-only entries still appear as titled rows and remain resolvable through title-based lookup.

Evidence

Head SHA: e988d5d5bf

Real behavior proof: session title contract end-to-end

Ran scripts/proof-session-title.ts against the patched modules — exercises sessions-patch.ts, session-label.ts, and session-utils.ts with real session entries (no mocks, no Telegram).

=== Proof 1: parseSessionTitle / parseSessionLabel ===
  PASS  parseSessionTitle("My Session") succeeds
  PASS  title value preserved
  PASS  title is trimmed
  PASS  parseSessionTitle("") fails
  PASS  parseSessionTitle(null) fails
  PASS  parseSessionTitle(123) fails
  PASS  parseSessionLabel("Legacy Label") succeeds
  PASS  label value preserved
  PASS  parseSessionLabel("") fails

=== Proof 2: applySessionTitle — set and clear ===
  PASS  set: title stored
  PASS  set: label mirror populated
  PASS  clear: title removed
  PASS  clear: label mirror removed

=== Proof 3: getSessionTitleFromEntry — priority ===
  PASS  title wins over label
  PASS  label used when no title
  PASS  empty entry → undefined
  PASS  null entry → undefined

=== Proof 4: sessionTitlesEqual ===
  PASS  NFC-equal strings match
  PASS  different strings don't match
  PASS  null left → false
  PASS  undefined right → false

=== Proof 5: sessions.create — set title on new session ===
  PASS  create with title succeeds
  PASS  title persisted
  PASS  label mirror set

=== Proof 6: /name <title> — rename session ===
  PASS  rename succeeds
  PASS  title updated
  PASS  label mirror updated

=== Proof 7: /name --clear — clear via title: null ===
  PASS  clear via title: null succeeds
  PASS  title cleared
  PASS  label mirror cleared

=== Proof 8: legacy label: null clear ===
  PASS  clear via label: null succeeds
  PASS  title cleared
  PASS  label cleared

=== Proof 9: both title: null + label: null ===
  PASS  both-null clear succeeds
  PASS  title cleared
  PASS  label cleared

=== Proof 10: reject mixed null/string ===
  PASS  title: null + label: string → rejected
  PASS  error message mentions mixed clear/set
  PASS  title: string + label: null → rejected
  PASS  error message mentions mixed clear/set

=== Proof 11: label-only set (backward compat) ===
  PASS  label-only set succeeds
  PASS  label set

=== Proof 12: title/label mismatch rejection ===
  PASS  title: Alpha + label: Beta → rejected
  PASS  error mentions mismatch

=== Proof 13: sessions.list — title projection (label-only entry) ===
  PASS  label-only entry projects title from label

=== Proof 14: sessions.resolve — title lookup matches label-only entry ===
  PASS  title lookup matches label-only entry

=== Proof 15: full round-trip — create → rename → clear → legacy lookup ===
  PASS  round-trip: create succeeds
  PASS  round-trip: title after create
  PASS  round-trip: rename succeeds
  PASS  round-trip: title after rename
  PASS  round-trip: label after rename
  PASS  round-trip: clear succeeds
  PASS  round-trip: title after clear
  PASS  round-trip: label after clear
  PASS  round-trip: legacy label-only resolves as title

  Results: 55 passed, 0 failed

Vitest: all touched tests pass on current head

node scripts/run-vitest.mjs run src/gateway/sessions-patch.test.ts src/auto-reply/reply/commands-name.test.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.create.test.ts src/gateway/sessions-resolve.test.ts
Gateway shard:  Test Files 14 passed (14), Tests 734 passed (734)
Auto-reply shard:  Test Files 1 passed (1), Tests 7 passed (7)
Total: 741 passed in 133.68s

Regression fix 1: nullable clear sentinels

Bug: sessions-patch.ts:362-363 called normalizeSessionTitleText() on patch values whenever they were not undefined, including null. Caused null.trim() to throw.

Fix: Check for null explicitly. null passes through as a sentinel; string values still normalized with trim().normalize("NFC").

Regression fix 2: mixed null/string title+label pairs

Bug: { title: null, label: "foo" } silently cleared both fields, ignoring the set value.

Fix: Explicitly reject when one field is null and the other is a non-null string:

if (
  (rawTitle === null && rawLabel !== undefined && rawLabel !== null) ||
  (rawLabel === null && rawTitle !== undefined && rawTitle !== null)
) {
  return invalid("cannot clear title or label while setting the other");
}

Docs

docs/tools/slash-commands.md updated: /name description now documents /name --clear.

Lint gate

check-lint passes on current head.

ClawSweeper P2 findings addressed (from previous review)

  1. sessions-patch.ts: compare title/label after parsing — Normalized with trim().normalize("NFC") before comparison.
  2. session-display.ts: add title to shared UI row contract — GatewaySessionRow in ui/src/ui/types.ts now declares title?: string.

Mantis live proof

@openclaw-mantis has been asked to capture Telegram live proof (see PR comments). The proof script above validates the same code paths end-to-end.

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 20, 2026
@clawsweeper

clawsweeper Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 24, 2026, 12:59 AM ET / 04:59 UTC.

Summary
The PR adds canonical session title support across gateway protocol schemas, durable session entries, create/patch/list/resolve paths, /name --clear, session-change events, UI display, docs, generated Swift models, and focused tests/proof script.

PR surface: Source +93, Tests +234, Docs 0, Other +304. Total +631 across 26 files.

Reproducibility: yes. at source level: current main only supports legacy label on the inspected schema/patch/name paths, while the PR body provides terminal proof for title create, patch, list, resolve, rename, clear, and legacy lookup behavior; I did not rerun tests in this read-only review.

Review metrics: 3 noteworthy metrics.

  • PR surface: +881/-250 across 26 files. The patch is large enough that maintainer review should focus on the session-state and protocol boundaries, not only the slash-command text.
  • Session API/state surfaces: 4 RPC schemas, 1 durable field, 1 event field changed. List, resolve, create, patch, persisted session metadata, and session-change events are compatibility-sensitive for clients and upgrades.
  • Generated client structs: 4 Swift request structs changed. Generated public initializers can affect downstream Swift callers even when the wire protocol change is additive.

Stored data model
Persistent data-model change detected: serialized state: packages/gateway-protocol/src/schema/sessions.ts, serialized state: scripts/proof-session-title.ts, serialized state: src/config/sessions/types.ts, serialized state: src/gateway/server-methods/sessions.ts, serialized state: src/gateway/session-event-payload.ts, serialized state: src/gateway/session-utils.test.ts, and 16 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Maintainer acceptance of title as the canonical session-name API with label as the compatibility mirror.
  • Attach live Telegram or equivalent chat proof for /name <title> and /name --clear.

Proof path suggestion
A live Telegram transcript would materially verify the user-visible slash-command output and clear path beyond terminal contract proof. Mantis is proof-only, so it must not be asked to change code or mutate GitHub state.
Use ClawSweeper's repair, apply, or automerge lanes for code changes, branch updates, labels, comments, PR repair, closes, or merges.

Risk before merge

  • [P1] The PR changes protocol request shapes, generated Swift model initializers, and durable SessionEntry metadata, so maintainers should explicitly accept the additive title/legacy-label compatibility contract before merge.
  • [P1] Although terminal proof covers the title contract, the user-visible /name --clear slash-command path would benefit from live Telegram/Desktop proof before landing because chat users will experience the behavior through channel transports.

Maintainer options:

  1. Approve the title contract before merge (recommended)
    Have a maintainer explicitly accept title as canonical while label remains a compatibility mirror, including the generated Swift and gateway protocol shape changes.
  2. Capture live chat proof
    Attach a short Telegram or equivalent chat proof showing /name <title> and /name --clear update the current session and leave title/label lookup consistent.
  3. Pause if title is not canonical
    If maintainers do not want a new canonical title API, pause or close this branch and keep the existing label-only contract until a narrower API direction is chosen.

Next step before merge

  • [P2] Maintainer review should decide the additive title protocol/durable-state contract and live chat proof expectations; there is no discrete repair finding for ClawSweeper to fix.

Security
Cleared: No dependency, lockfile, workflow, install, release, permissions, download, or secret-handling changes were found; the added proof script is local assertion code only.

Review details

Best possible solution:

Land after maintainer acceptance of canonical title as the session name contract, keeping the legacy label mirror and adding live chat proof for /name and /name --clear.

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

Yes at source level: current main only supports legacy label on the inspected schema/patch/name paths, while the PR body provides terminal proof for title create, patch, list, resolve, rename, clear, and legacy lookup behavior; I did not rerun tests in this read-only review.

Is this the best way to solve the issue?

Yes, conditionally: centralizing title normalization and mirroring to legacy label is the best implementation shape I found, provided maintainers accept the new canonical title API and generated-client compatibility impact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 2ab3b223ed69.

Label changes

Label justifications:

  • P2: This is a normal-priority session naming/API improvement with bounded but real gateway/UI/session-state blast radius.
  • merge-risk: 🚨 compatibility: Merging changes protocol fields and generated Swift request structs while preserving legacy label behavior, which still needs maintainer acceptance as an upgrade contract.
  • merge-risk: 🚨 session-state: Merging changes durable session metadata and title/label resolution semantics for create, patch, list, resolve, and session-change flows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes after-fix terminal proof from scripts/proof-session-title.ts showing the title contract and reports focused Vitest runs passing on the touched session paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix terminal proof from scripts/proof-session-title.ts showing the title contract and reports focused Vitest runs passing on the touched session paths.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes user-visible slash-command naming and clear behavior that can be demonstrated in a short Telegram Desktop/live proof, even though the implementation is channel-generic.
Evidence reviewed

PR surface:

Source +93, Tests +234, Docs 0, Other +304. Total +631 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 16 229 136 +93
Tests 7 347 113 +234
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 304 0 +304
Total 26 881 250 +631

Acceptance criteria:

  • [P1] Review PR body proof from scripts/proof-session-title.ts showing 55 passed assertions.
  • [P1] Review PR body command: node scripts/run-vitest.mjs run src/gateway/sessions-patch.test.ts src/auto-reply/reply/commands-name.test.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.create.test.ts src/gateway/sessions-resolve.test.ts.
  • [P1] Check CI rollup for current head ad010aa0a8034c627e2e574bcf3ab33c4d23559b, especially protocol, lint, test-types, and gateway/session lanes.
  • [P1] Capture Telegram or equivalent live chat proof for /name <title> and /name --clear before merge if maintainers require user-visible transport evidence.

What I checked:

  • Root review policy read: Root AGENTS.md and scoped guides for gateway, gateway server methods, UI, docs, and scripts were read; the review applied the session-state/protocol compatibility guidance and read-only constraint. (AGENTS.md:1, 2ab3b223ed69)
  • Current main lacks canonical title schema: Current main SessionsListParams, SessionsResolveParams, and SessionsCreateParams include label but no title, so the requested title contract is not already implemented on main. (packages/gateway-protocol/src/schema/sessions.ts:157, 2ab3b223ed69)
  • Current main patch path is label-only: Current main sessions.patch only handles patch.label; it does not accept or mirror a canonical title. (src/gateway/sessions-patch.ts:351, 2ab3b223ed69)
  • PR adds title to protocol surfaces: The potential merge adds title to list, resolve, create, and patch schemas while preserving label. (packages/gateway-protocol/src/schema/sessions.ts:157, c92329aed5fd)
  • PR centralizes title/label normalization: The new session title helper normalizes title text, falls back from title to legacy label, mirrors title writes into label, and compares normalized names. (src/sessions/session-label.ts:43, c92329aed5fd)
  • PR handles null clears and mixed title/label pairs: The patch path preserves null clear sentinels, rejects ambiguous mixed null/string title+label pairs, rejects mismatched title/label strings, and applies the title helper for durable writes. (src/gateway/sessions-patch.ts:356, c92329aed5fd)

Likely related people:

  • BSG2000: PR feat(commands): add /name to rename the current session from chat #88581 introduced the /name chat command that writes legacy label, which this PR migrates toward canonical title while preserving the label mirror. (role: feature-history contributor; confidence: medium; commits: b48238aa88b0; files: src/auto-reply/reply/commands-name.ts)
  • Josh Lehman: Current-main blame/log for central session patch/name helper files points to the broad session accessor refactor refactor: add abort target session accessor #96201; local history is grafted, so this is a routing hint rather than feature authorship. (role: recent area contributor; confidence: low; commits: f8ed4de460f7; files: src/gateway/sessions-patch.ts, src/sessions/session-label.ts, src/auto-reply/reply/commands-name.ts)
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.

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.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jun 20, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jun 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 20, 2026
@jason-allen-oneal
jason-allen-oneal marked this pull request as ready for review June 21, 2026 02:45
@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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.

@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@openclaw-mantis telegram live proof: verify /name <title> and /name --clear update the same session while gateway title and legacy label lookup still agree.

@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XL and removed size: L labels Jun 21, 2026
@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 21, 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.

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 21, 2026
@jason-allen-oneal
jason-allen-oneal force-pushed the fix/session-title-contract branch from 3f28ea6 to ad010aa Compare June 22, 2026 16:03
@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 22, 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.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 23, 2026
@jason-allen-oneal

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. labels Jun 24, 2026
@clawsweeper
clawsweeper Bot temporarily deployed to qa-live-shared June 24, 2026 05:02 Inactive
@openclaw-mantis

Copy link
Copy Markdown
Contributor

Mantis Telegram Desktop Proof

Summary: Mantis captured native Telegram Desktop before/after GIF evidence for the /name --clear session naming change.

Main screenshot This PR screenshot
Baseline native Telegram Desktop screenshot Candidate native Telegram Desktop screenshot
Main This PR
Baseline native Telegram Desktop proof GIF Candidate native Telegram Desktop proof GIF

Motion-trimmed clips:

Raw QA files: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-95182/run-28076300381-1/index.json

This branch was previously deployed

1 inactive deployment
qa-live-shared — ad010aa0 Deployed Jun 24, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #223317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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.

4 participants