Skip to content

fix(sessions): keep pins on root sessions only - #140748

Merged
steipete merged 2 commits into
mainfrom
claude/subagent-pinned-bug-6de80f
Sep 7, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/subagent-pinned-bug-6de80f

Conversation

@steipete

@steipete steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Problem

A session pin is a bare pinnedAt timestamp on the session entry, and the Gateway stamped it on any key. Nothing enforced "pins are for root sessions": the agent sessions tool, the Sessions page menu (which lists raw Gateway rows), promoted child rows in the sidebar, and drag-to-pin all reached sessions.patch { pinned: true } for child sessions. On a team deployment a spawned child dashboard session was pinned through a batch sessions.patch, and because the sidebar's pinned zone is built from any projected root row with pinned: true (the active session is always promoted to a root row), the child rendered as a top-level pinned card next to the navigation routes.

Solution

  • One config-layer helper decides pinnability: not a subagent:* key, no non-empty spawnedBy, no non-empty parentSessionKey.
  • sessions.patch rejects pinned: true on such entries with cannot pin a child session; pin its parent session instead, and drops a stale pinnedAt on any successful patch to an unpinnable entry.
  • Row projection (sessions.list and session events), list ordering, and store-maintenance preservation ignore child pins, so existing child pins disappear without a migration.
  • Control UI: sidebar rows, the session menu, the Sessions page, the chat pane header, and drag-to-pin gate on a lineage-derived pinnable fact (shared helper) instead of the sidebar's child-projection flag, with a localized disabled reason.
  • The agent tool schema describes the root-only rule; docs updated.

Impact

  • Child/subagent sessions can no longer be pinned from the UI or the agent tool; the error text says to pin the parent instead.
  • Existing child pins stop showing and no longer protect the entry from maintenance; unpinning a child still works.
  • No schema, config, or doctor changes.

Evidence

  • pnpm check:changed: all lanes green after fixing a test-fixture type error and trimming the pruning test under the file line cap (final lint on the touched file green).
  • node scripts/run-vitest.mjs src/gateway/sessions-patch.test.ts src/gateway/session-utils.test.ts src/config/sessions/store.pruning.test.ts src/agents/tools/sessions-tool.batch.test.ts: 3 shards passed (366 + 60 + 12 tests).
  • node scripts/run-vitest.mjs ui/src/components/app-sidebar.test.ts ui/src/pages/sessions/sessions-page.test.ts ui/src/pages/chat/chat-pane-session-menu.test.ts ui/src/components/app-sidebar-session-projection.test.ts ui/src/components/app-sidebar-session-narration.test.ts: 5 files, 435 tests passed.
  • New tests were run red on the previous code (Gateway rejection, stale-pin cleanup, projection/ordering, maintenance preservation, sidebar/menu/Sessions page/chat header affordances, drag-to-pin).
  • Independent autoreview clean at the P0 threshold before landing.

A pin was a bare pinnedAt stamp that the Gateway accepted for any
session key, so a spawned child session could be pinned through the
agent sessions tool, a Sessions page batch action, or a promoted child
row, and the sidebar then rendered it as a top-level pinned card.

Define pinnability once: a session is pinnable only when its key is not
a subagent key and its entry carries no spawnedBy or parentSessionKey.
sessions.patch rejects child pins with a clear error and drops a stale
child pin on the next write; list projection, ordering, and maintenance
preservation ignore child pins, so existing child pins simply disappear.
The Control UI hides pin affordances by lineage instead of the sidebar's
child-projection fact, and the agent tool describes the root-only rule.
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 7, 2026, 12:39 AM ET / 04:39 UTC.

ClawSweeper review

What this changes

Restricts session pins to root conversations across the Gateway, agent tool, and Control UI, and stops honoring existing child pins during listing and maintenance.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses behavior still present on current main. The updated RPC fixture is appropriate and no discrete correctness defect was found, but the previously identified persisted-retention compatibility gap remains unresolved.

Priority: P2
Reviewed head: 949279c087f1c10f5f8a75af717eb8bf5172f250
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation is focused and has useful regression coverage, but the unverified persistent-retention transition limits merge confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate; focused tests are supplemental, while persisted upgrade evidence remains a separate storage-compatibility requirement.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate; focused tests are supplemental, while persisted upgrade evidence remains a separate storage-compatibility requirement.
Evidence reviewed 9 items Current main still permits child pins: The fetched main implementation checks whether a session is archived before setting pinnedAt, but has no root-session eligibility check.
Introduced mutation and retention changes: The verified merge-base-to-head diff rejects child pin requests, removes existing child pinnedAt values on successful metadata patches, and excludes child pins from the shared maintenance preservation guard.
Persistent maintenance boundary: SQLite maintenance reads existing session metadata, invokes the changed pruning and capping policies, writes archival state, and plans removal of unreferenced session state with transcript archival. This establishes a persistent retention change rather than only a sidebar presentation change.
Findings None None.
Security None None.

How this fits together

Session pins organize conversations in the Control UI and protect session records from maintenance. The Gateway processes pin requests against stored session lineage, then projects those records for browsing and cleanup.

flowchart TD
  A[UI or agent pin request] --> B[Gateway session patch]
  C[Stored session lineage] --> B
  B --> D{Root session?}
  D -->|Yes| E[Persist pin]
  D -->|No| F[Reject pin request]
  C --> G[Session listing and maintenance]
  E --> G
  G --> H[Sidebar ordering and retention]
Loading

Decision needed

Question Recommendation
Should existing child pins lose retention protection in this change, or should that transition wait for persisted upgrade and recovery proof? Validate before retiring protection: Require persisted legacy-pin maintenance and recovery evidence before accepting the retention transition.

Why: The maintainer-authored body establishes root-only pin intent, but withdrawing protection from existing stored sessions has consequences beyond correcting their sidebar placement.

Before merge

  • Resolve merge risk (P1) - Existing child pins disappear and lose maintenance protection without an explicit unpin. Eligible ordinary children can be archived, synthetic children removed, and cap-archived children considered for disk-budget eviction; persisted upgrade and recovery outcomes remain unverified.
  • Complete next step (P2) - Provide persisted legacy child-pin upgrade, maintenance, transcript-retention, and recovery evidence, and record acceptance of the retention transition or preserve existing protection.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +59, Tests +185, Docs +7. Total +251 across 34 files.

View PR surface stats
Area Files Added Removed Net
Source 17 71 12 +59
Tests 11 207 22 +185
Docs 6 19 12 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 34 297 46 +251

Review metrics

None.

Mantis proof suggestion

Web UI chat evidence could confirm that promoted children lack pin affordances while root pinning still works; storage recovery requires separate evidence. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis verify root-session pinning and promoted-child pin menu and drag behavior in web UI chat, including after reload, and return redacted screenshots and interaction results.

Merge-risk options

Maintainer options:

  1. Verify the persisted transition (recommended)
    Demonstrate fresh root/child behavior and legacy child-pin outcomes after store reopening, maintenance, and recovery, including retained transcripts.
  2. Preserve legacy retention
    Separate the browsing correction from retiring existing maintenance protection until its upgrade contract is accepted.

Technical review

Best possible solution:

Enforce root-only browsing pins with an explicitly accepted, demonstrated transition for legacy child retention, preserving existing protection until that transition is validated.

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

Yes, from source: current main accepts a pin on a spawned child, and the reported promoted-row path can expose that child as pinned. This review did not execute a runtime reproduction.

Is this the best way to solve the issue?

The Gateway eligibility check and matching UI affordances are a focused repair; the additional legacy-retention transition needs persisted compatibility evidence before the complete solution is accepted.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4394672f2573.

Labels

Label justifications:

  • P2: Corrects a bounded session-organization problem without evidence of an urgent current runtime outage.
  • merge-risk: 🚨 session-state: The changed maintenance guard removes protection from existing persisted child pins, potentially archiving or removing previously protected sessions.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate; focused tests are supplemental, while persisted upgrade evidence remains a separate storage-compatibility requirement.

Evidence

What I checked:

  • Current main still permits child pins: The fetched main implementation checks whether a session is archived before setting pinnedAt, but has no root-session eligibility check. (src/gateway/sessions-patch.ts:366, 4394672f2573)
  • Introduced mutation and retention changes: The verified merge-base-to-head diff rejects child pin requests, removes existing child pinnedAt values on successful metadata patches, and excludes child pins from the shared maintenance preservation guard. (src/config/sessions/store-maintenance.ts:566, 949279c087f1)
  • Persistent maintenance boundary: SQLite maintenance reads existing session metadata, invokes the changed pruning and capping policies, writes archival state, and plans removal of unreferenced session state with transcript archival. This establishes a persistent retention change rather than only a sidebar presentation change. (src/config/sessions/session-accessor.sqlite-maintenance.ts:426, 949279c087f1)
  • Storage compatibility policy: The storage review checkpoint explicitly includes changed retention and interpretations of existing durable data, even without a schema-version change, and calls for upgrade, rollback, deletion, and validation limits to be documented. Public docs: docs/reference/database-schemas.md. (docs/reference/database-schemas.md:430, 949279c087f1)
  • Re-review continuity: Compared with the previous reviewed head, only the RPC test fixture changed: the pin/archive sequence now uses the existing Discord group root. The prior review contained no findings and requested persisted legacy-pin upgrade and recovery evidence; production retention behavior remains unchanged. (src/gateway/server.sessions.store-rpc.test.ts:352, 949279c087f1)
  • Captured validation evidence: The supplied PR body at sourceRevision 8360b79b0df0fc92e4aaa4874b82197b522dea908c8f1cc49e7248b2c3bac132 reports focused Gateway, agent, pruning, and UI tests, including pre-fix failures. It explicitly describes retiring child-pin maintenance protection, but provides no persisted-store reopening or recovery observations. No tests were executed during this read-only review. (949279c087f1)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vyctor H. Brzezowski: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate persisted legacy child-pin outcomes through reopening and maintenance, including transcript retention and recovery, or preserve their existing retention protection.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-07T03:59:16.887Z sha 7e689c5 :: blocked before merge. :: none

Update the existing session-store RPC integration sequence to pin and archive its Discord group root fixture. Child pins are intentionally rejected by PR #140748; dedicated patch tests cover that rejection.
@steipete
steipete merged commit e3c0531 into main Sep 7, 2026
181 checks passed
@steipete
steipete deleted the claude/subagent-pinned-bug-6de80f branch September 7, 2026 04:52
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
* fix(sessions): keep pins on root sessions only

A pin was a bare pinnedAt stamp that the Gateway accepted for any
session key, so a spawned child session could be pinned through the
agent sessions tool, a Sessions page batch action, or a promoted child
row, and the sidebar then rendered it as a top-level pinned card.

Define pinnability once: a session is pinnable only when its key is not
a subagent key and its entry carries no spawnedBy or parentSessionKey.
sessions.patch rejects child pins with a clear error and drops a stale
child pin on the next write; list projection, ordering, and maintenance
preservation ignore child pins, so existing child pins simply disappear.
The Control UI hides pin affordances by lineage instead of the sidebar's
child-projection fact, and the agent tool describes the root-only rule.

* test(sessions): use root fixture for pin archive RPC coverage

Update the existing session-store RPC integration sequence to pin and archive its Discord group root fixture. Child pins are intentionally rejected by PR openclaw#140748; dedicated patch tests cover that rejection.
SunnyShu0925 added a commit to SunnyShu0925/openclaw that referenced this pull request Sep 10, 2026
The root-only pin policy from openclaw#140748 rejected any session with a
non-empty parentSessionKey. Ordinary durable dashboard sessions
auto-parent to the agent main root (agent:<id>:main) for flow-up
notices and sidebar threads, so they were incorrectly treated as
nested children and could not be pinned.

Distinguish the auto-Home parent from genuine nested-child lineage:
when parentSessionKey equals the session's own agent main root, the
session is still top-level and remains pinnable. The spawnedBy check
stays strict; subagent keys and truly nested children are still
rejected.

Fixes openclaw#142673
Patrick-Erichsen pushed a commit to SunnyShu0925/openclaw that referenced this pull request Sep 15, 2026
The root-only pin policy from openclaw#140748 rejected any session with a
non-empty parentSessionKey. Ordinary durable dashboard sessions
auto-parent to the agent main root (agent:<id>:main) for flow-up
notices and sidebar threads, so they were incorrectly treated as
nested children and could not be pinned.

Distinguish the auto-Home parent from genuine nested-child lineage:
when parentSessionKey equals the session's own agent main root, the
session is still top-level and remains pinnable. The spawnedBy check
stays strict; subagent keys and truly nested children are still
rejected.

Fixes openclaw#142673
Patrick-Erichsen added a commit that referenced this pull request Sep 15, 2026
* fix(sessions): allow pinning Home-parented dashboard sessions

The root-only pin policy from #140748 rejected any session with a
non-empty parentSessionKey. Ordinary durable dashboard sessions
auto-parent to the agent main root (agent:<id>:main) for flow-up
notices and sidebar threads, so they were incorrectly treated as
nested children and could not be pinned.

Distinguish the auto-Home parent from genuine nested-child lineage:
when parentSessionKey equals the session's own agent main root, the
session is still top-level and remains pinnable. The spawnedBy check
stays strict; subagent keys and truly nested children are still
rejected.

Fixes #142673

* chore: retrigger CI (flaky checks-node-compact-large-12 timeout)

* fix(sessions): allow pinning Home-parented dashboard sessions

Resolve max-lines lint regression (702>700) in sessions-patch.ts: call
isPinnableSessionEntry without the explicit cfg-aware mainKey and rely on
its internal default fallback. The two paths are production-equivalent
(applySessionDefaults normalizes mainKey to 'main'), as documented below.

Closes #142673

* fix(sessions): unify Home pin policy and verify retention boundaries

* chore(sessions): satisfy pin policy lint guards

---------

Co-authored-by: Patrick Erichsen <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…aw#143250)

* fix(sessions): allow pinning Home-parented dashboard sessions

The root-only pin policy from openclaw#140748 rejected any session with a
non-empty parentSessionKey. Ordinary durable dashboard sessions
auto-parent to the agent main root (agent:<id>:main) for flow-up
notices and sidebar threads, so they were incorrectly treated as
nested children and could not be pinned.

Distinguish the auto-Home parent from genuine nested-child lineage:
when parentSessionKey equals the session's own agent main root, the
session is still top-level and remains pinnable. The spawnedBy check
stays strict; subagent keys and truly nested children are still
rejected.

Fixes openclaw#142673

* chore: retrigger CI (flaky checks-node-compact-large-12 timeout)

* fix(sessions): allow pinning Home-parented dashboard sessions

Resolve max-lines lint regression (702>700) in sessions-patch.ts: call
isPinnableSessionEntry without the explicit cfg-aware mainKey and rely on
its internal default fallback. The two paths are production-equivalent
(applySessionDefaults normalizes mainKey to 'main'), as documented below.

Closes openclaw#142673

* fix(sessions): unify Home pin policy and verify retention boundaries

* chore(sessions): satisfy pin policy lint guards

---------

Co-authored-by: Patrick Erichsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

1 participant