Skip to content

fix: session-scoped members cannot start an unused agent conversation - #197151

Merged
freeqaz merged 4 commits into
mainfrom
fix/chat-scope-first-session
Nov 11, 2026
Merged

freeqaz merged 4 commits into
mainfrom
fix/chat-scope-first-session

Conversation

@freeqaz

@freeqaz freeqaz commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a person with only operator.sessions.write (for example a chat-only member behind a trusted proxy that caps the connection's scopes) who opens a fresh agent's chat sees "Couldn't load this conversation: Session "agent:main:main" was not found." and a disabled composer ("You need permission to send messages in this session."). It only starts working after someone with broader access has chatted once.

User Impact

User impact: session-scoped people can open an agent's unused main conversation and send its first message, which makes them its creator. They get no new administrative, configuration, device, approval, or cross-session access.

Why This Change Was Made

Two gates disagreed with what the Gateway already allows. chat.send from a session writer to the absent main conversation already succeeds and records the caller as creator, and chat.history/chat.startup already return an empty conversation. But:

  • sessions.messages.subscribe treated every absent row as hidden for session-scoped readers, so the Control UI's foreground subscription failed with not-found.
  • The Control UI composer required an owner or admin sharingRole for session writers, and an absent session has no row.

The Gateway now admits a subscription to an absent session only when the caller holds operator.sessions.write, its role may start sessions for that agent (the same agent limit chat.send applies), and the key is the agent's own main conversation (same canonical store key). Only sessions.messages.subscribe opts in; other session reads, session-only readers, every other absent key, and existing rows keep the current not-found behavior. Admission grants nothing after it: every event is still authorized against the subscriber's current role, scopes and the row's visibility when it is written to the socket, and a missing row delivers nothing.

The Control UI enables chat.send for a session writer only when a successful read on the current connection proved that the session has no row (committed history without a session ID). Unproven absence, existing member/viewer rows, and other mutations still need ownership. Absence never grants broader or administrative scopes.

Evidence

Real Gateway and Control UI

On a remote test VM: a Gateway child process built from this head, a header-injecting trusted proxy (x-forwarded-user plus x-openclaw-scopes: operator.sessions.write, one shared identity as in a proxy-capped deployment), the real Control UI in headless Chromium, and a stub Responses model on loopback (no real credentials). The proof harness was a throwaway Vitest file run against this checkout and is not part of the diff. Frames below are from the browser's WebSocket, trimmed.

First turn, one browser with only operator.sessions.write:

Before (the code before this change) After (this head)
Before: Couldn't load this conversation, Session agent:main:main was not found, and a disabled composer After: the first message and the stub model's reply in the main session
  • Before: sessions.messages.subscribe {key: "agent:main:main"} → Session "agent:main:main" was not found.; the page shows "Couldn't load this conversation" and "You need permission to send messages in this session."
  • After: hello reports scopes: ["operator.sessions.write"]; the same subscribe → subscribed: true, 0 messages, no session ID; the composer is editable; chat.send runs one model turn and the reply renders.

Admitted socket, then a foreign draft and revocations. Two browsers on one Gateway with roles: a member capped by its route to operator.sessions.write, an owner capped to operator.read,operator.write; an administrator changes the member's role with users.setRole.

Step What the member's admitted socket got
Member's Control UI opens absent main sessions.messages.subscribe → subscribed: true, 0 messages, no session ID
Owner creates agent:main:main as a draft and runs a turn no events (only replies to its own requests); its chat.send → "Session-scoped writes require your own session."; a fresh subscribe to main → not found
Control: owner shares main, runs a turn session.message, chat, agent and sessions.changed events (26)
Member's role narrowed to sessions.others: none (same scopes) socket stays open; no events for the owner's next turn; reads of main → not found
Member's role loses its scopes the Gateway closes the socket; nothing delivered after the close
Member after the owner's draft turn Member after its scopes were revoked
Member's main conversation still shows No messages yet after another person's draft turn Member's Control UI reconnecting after the Gateway closed its socket

Tests

Red/green on the same VM (red = the code before this change, green = this head):

  • src/gateway/server.chat-main-session-narrow.test.ts (new, real Gateway, trusted proxy):
    • A shared browser identity capped to operator.sessions.write subscribes to absent agent:main:main and gets an empty, session-less snapshot; another absent key stays not-found; chat.send succeeds; config.get stays FORBIDDEN.
    • An admitted subscriber to absent main receives nothing from another creator's draft main created after the subscribe, and its chat.send there is refused. After the owner shares main the same socket receives the conversation; after the member's role narrows to no other sessions it receives nothing with the socket open; after its role loses its scopes the socket is closed.
    • Both red on main (subscribe not-found). With the send-time delivery check removed from the broadcaster, the second test fails at the draft step (expected [ 'chat', 'session.message' ] to deeply equal []).
  • src/gateway/server-methods.session-main-start.test.ts (new): admission with and without gateway roles (red on main); another absent key, a session-only reader and another creator's draft main stay not-found with no subscriber registered; the role's agent limit; main key aliases, including a session.mainKey override (red on main) and a non-main key under it; sessions.files.list and sessions.diff on the absent main stay not-found after the subscribe.
  • ui/src/lib/session-method-access.test.ts and ui/src/pages/chat/chat-main-session-absent.test.ts (new): the composer allows the first turn only after a read on the current connection proved the session absent. Once a row arrives, row-based gating takes over; a later read that finds the session, or a new connection epoch, removes the exemption (red on main).
  • ui/src/e2e/guest-absent-main-session.e2e.test.ts (Control UI mock Gateway e2e): the composer is editable on an absent main and sends chat.send.

Checks on this head: the touched Gateway tests (13 passed) and UI unit tests (17 passed), the mock-Gateway e2e above, tsgo test:src/test:ui, oxlint, the format check and the max-lines check pass; production code is unchanged since the previous head, where tsgo core/ui and the consumer tests passed.

Test lines: this adds config/test-lines-allocations/197151-chat-scope-first-session.txt for exactly the net growth (482 lines) instead of raising the shared scalar. The growth is the real-Gateway proof that admission adds no delivery after it, plus the regression tests for the two gates; duplicated in-process broadcaster and row-gating cases were folded into those.

Risks

  • session.dmScope defaults to main, so channel DMs share agent:main:main. Session writers could already claim that conversation through chat.send or sessions.create before this change. This PR does not widen that, but deployments that give people session-only access alongside default DM routing should set session.dmScope to a per-peer value such as per-channel-peer.
  • The subscribe exemption is checked against the caller's current scopes, role and agent limit while the subscription is admitted. After that, each event is filtered by current role and visibility as before, and a missing row delivers nothing (tested above).
  • The UI exemption depends on a committed absent read for the same connection, session list, and epoch. A stale proof can only leave the composer enabled for a send the Gateway still refuses on its own: if another person creates a draft main after the member opened it, the member's composer stays editable but chat.send is refused.

A person with only operator.sessions.write who opened an agent's main
conversation before anyone had used it saw "Session agent:main:main was not
found" and a disabled composer, although chat.send would already create the
conversation and record them as its creator.

The Gateway now admits sessions.messages.subscribe to an absent session only
for a session writer and only for the agent's own main conversation. Other
absent keys, session-only readers and existing rows keep the hidden-session
answer; event delivery still filters each event by current visibility.

The Control UI enables the first chat.send for a session writer only after a
read on the current connection proved the session has no row. Unproven
absence, member or viewer rows and other mutations still need ownership.
@clawsweeper

clawsweeper Bot commented Nov 11, 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 size: M labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Allows session writers to open an agent’s unused main conversation and send its first message.

Example: A browser with only operator.sessions.write opens unused agent:main:main.

  • Before: The subscription returns not-found and the composer is disabled.
  • After: The subscription returns empty history and the first message creates the conversation for its sender.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with inspected shipped-entry-point proof, final-effect denial coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Inspected screenshots and public WebSocket observations exercise real Chromium Control UI against an isolated trusted-proxy Gateway with a loopback Responses stub: first-turn success, foreign-draft denial, shared delivery, denial after role narrowing, and socket closure after scope revocation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Session-only writers see a not-found error and disabled composer when opening an agent’s unused main conversation.
Reason: Restores the existing own-work contract without adding administrative access, configuration, or a new capability.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it fixes a current permission mismatch, preserves delivery authorization, and has no actionable findings; the exact-head CI gate remains pending.

Priority: P2
Reviewed head: 1cb75a62c4adf60a8e56d8c6381608a440a8cc2f

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI derives composer access from negotiated scopes and accepted history, while Gateway subscription and sharing owners authorize admission and outgoing session events.

flowchart LR
  A[Session writer browser] --> B[Subscription admission]
  B --> C[Current scopes and agent policy]
  B --> D[Accepted empty history]
  D --> E[Composer access]
  E --> F[Existing chat send owner]
  F --> G[Current event visibility]
  G --> A
Loading

Technical review

Best possible solution:

Align subscription and composer admission with existing first-turn authority while preserving current authorization at every event delivery.

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

Current-main gates explain the supplied before screenshot and reported base-red regressions; this read-only review did not execute a reproduction.

Is this the best way to solve the issue?

The fix uses existing retained-read, accepted-history, and composer-access owners without adding storage or a competing creation path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 40168696c2d0.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +73, Tests +482, Docs +6, Other +5. Total +566 across 13 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 6 92 19 +73
Tests 5 482 0 +482
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 0 +5
Total 13 585 19 +566

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +92/-19; tests +482/-0 The production change extends existing access owners; regression growth covers distinct admission, transport-delivery, and connection-bound composer contracts with a dedicated allocation.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Session-only writers cannot open an unused main conversation through the Control UI despite already having first-turn creation authority.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-11T08:58:22.816Z sha c35a6c7 :: needs real behavior proof before merge. :: [P3] Fund the added regression tests within the test-line budget
  • reviewed 2026-11-11T10:36:01.298Z sha 1cb75a6 :: needs maintainer review before merge. :: none

Reviewed November 11, 2026, 5:42 AM ET / 10:42 UTC (Revision 3).

A session writer whose role excludes an agent could subscribe to that
agent's unused main conversation and learn whether it existed, although
its first turn there would be refused. The startable-main check now also
requires the same agent limit that chat.send applies.

The relaxation now lives only in the subscribe opt-in of the retained
session read. The copy in the shared target read was reachable only from
sessions.describe and process-stop checks, which never needed it.

Tests move to their own file and cover the agent limit, main key aliases,
events from another creator's draft main after an early subscribe,
refused turns on another creator's main, other reads of an absent main,
and the Control UI falling back to row-based gating once a row arrives.
chat.history and chat.startup answer an absent conversation with an empty
history for every caller; only a subscription, and reads that need an existing
conversation, return the hidden not-found answer.
…n or revoked delivery

The real-Gateway narrow test now drives one admitted subscriber to an
absent agent:main:main through the rest of its lifetime: another creator's
draft main and its turns stay hidden (and the subscriber's chat.send there
is refused), a shared main is delivered, a role narrowed to no other
sessions keeps the socket but receives nothing, and a role that loses the
connection's scopes closes it. With the send-time delivery check removed
from the broadcaster, the test fails at the draft step.

That replaces the in-process broadcaster case and the separate foreign-main
chat.send case in server-methods.session-main-start.test.ts, folds the
non-main override key into the alias table, and drops the duplicate viewer
row cases from the UI unit and mock-Gateway e2e tests, which row gating
already covers.

The remaining net test growth (482 lines) gets its own allocation record
instead of a scalar raise.
@freeqaz

freeqaz commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Nov 11, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 11, 2026
@freeqaz
freeqaz merged commit ad4e676 into main Nov 11, 2026
151 of 153 checks passed
@freeqaz
freeqaz deleted the fix/chat-scope-first-session branch November 11, 2026 12:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…openclaw#197151)

A browser connection capped at operator.sessions.write could not open an agent's unused main conversation: the subscription returned not-found and the Control UI disabled the composer, so a chat-only user could not send the first turn. Such a writer may now subscribe to its own agent's absent main conversation (empty history), when its role may start sessions for that agent; the composer allows the first send only after a read on the current connection proved the conversation absent. Delivery is still re-authorized per event: foreign drafts deliver nothing, a narrowed role delivers nothing, revoked scopes close the socket.
obviyus added a commit that referenced this pull request Nov 22, 2026
## Problem

Open a brand-new main chat (no messages yet, for example right after onboarding sets a model). Session Details shows a red "Session process access changed; refresh the conversation." with Retry until the first reply arrives. The Gateway log shows three refused reads for the same chat:

- `sessions.processes.list` → `FORBIDDEN` "Session process access changed; refresh the conversation."
- `mcp.app.discover` → `FORBIDDEN` "The requested session is unavailable; open an existing session first."
- `talk.catalog` → `INVALID_REQUEST` "No session found: agent:main:main"

A config hot reload is not needed: a fresh profile with a model already configured shows the same three refusals.

![Before: new chat shows the process access alert](https://github.com/user-attachments/assets/da479b13-8826-428d-b009-f85f9c914719)

## Root cause

The agent's main conversation has no session row until its first turn creates it. The chat still starts session-scoped reads for it on open:

- Session Details reads processes as soon as it renders (`ui/src/pages/chat/chat-pane-layout-render.ts:293`, process Details since #175041). The Gateway has no row to bind the list to and answers with the access-changed error (`src/gateway/server-methods/session-processes.ts:69-79`, since #164061).
- The composer mounts MCP discovery for the chat. The composer already has a `sessionAdmitted` gate for provisional sessions (`chat-composer-view.tsx:414`, #166865), but the chat pane never set it. Discovery needs a session authority, which needs a row (`src/gateway/session-access-authority.ts:246`).
- The composer reads the session-scoped Talk catalog. The catalog only uses the key to pick the agent, but `talk.catalog` refused the missing row (`src/gateway/talk/handlers/catalog.ts:536`). Subscriptions already admit the caller's own unstarted main conversation (`isStartableMainSession`, #197151).

v2026.11.6 has the same chat pane and process code.

## Fix

Each reader is fixed at the owner of the fact it depends on:

| Read | Depends on | Owner and fix |
|---|---|---|
| `sessions.processes.list` | the row's `sessionId` | Control UI: Details stops offering process reads once the chat's history read proved the session absent (`isChatSessionProvenAbsent`, #197151). A cold load of an existing chat keeps its Details layout while rows load. |
| `mcp.app.discover` | a session authority built from the row | Control UI: the chat pane sets the composer's existing `sessionAdmitted` gate from the selected row, so composer extensions mount once it exists |
| `talk.catalog` | only the agent named by the key | Gateway: answers the caller's own unstarted main conversation from its agent (same `isStartableMainSession` rule as subscriptions); other missing or hidden keys still get "No session found" |

Holding `talk.catalog` in the UI instead would keep dictation unavailable for the first message, and the protocol has no agent-only form of the request.

Same PR, first send (two causes, both at their owner):

- **Diff baseline (session creation owner).** The first turn captures the session diff baseline (`sessionDiffBaseline`, the files that existed before the session) about half a second after `chat.send` creates the row. A diff read in that window either showed pre-existing workspace files as session changes or was refused with "Session workspace changed during file access" when the baseline landed. A new operator conversation now records the pending baseline claim (`sessionDiffBaselineCapture`) with its row, as `sessions.create` already does (`buildNewSessionCreationFields` in `src/config/sessions/session-diff-baseline-capture.ts`), and the diff answers "no changes" while the claim is pending (`src/gateway/server-methods/sessions-diff.ts`). The first turn's existing capture settles the claim.
- **Skill-library selection (workspace owner).** The first turn writes an empty selection (`librarySelections: []`) into a row that had none, and the session file workspace compared `undefined` with `[]` strictly. The sandbox owner already treats both as "no selection" (`librarySelections?.length`); the workspace check now does too.

The existing access-change refusals (replaced row, revoked sharing) are unchanged.

## Impact

- A new chat opens without an error. Processes and MCP controls appear after the first turn, which is when they can have content. The first message can be dictated.
- No protocol or schema change.

![After: new chat opens without the alert](https://github.com/user-attachments/assets/fccbce31-4a42-4e73-a9b5-4f8d0adb2460)

## Evidence

- Real-Gateway Control UI e2e `ui/src/e2e/chat-new-session-readers.real-gateway.e2e.test.ts`: opens `agent:main:main` before its first turn at 1600x900, sends the first message, checks that no non-retryable Gateway read failed and that process, MCP and diff reads succeed after the row exists. Red on the merge base (the three refusals above), green on this branch.
- `src/gateway/talk/handlers/catalog.test.ts` "answers the caller's unstarted main conversation from its agent": red on the merge base, green here. A missing non-main key and a caller who cannot start the conversation still get "No session found".
- `src/gateway/server-methods/sessions-diff-reset.test.ts` "shows no changes for a new operator conversation before its first turn captures the baseline": creates the row through the real reply session init, then reads the diff of a repo with a pre-existing file. Red on the merge base (the pre-existing file is listed as a session change), green here.
- `src/gateway/server-methods/session-file-live-read.test.ts` "keeps a diff read across the first turn recording no library skills": red on the merge base, green here; a real selection change still invalidates.
- Isolated Gateway with a real provider, fresh agent main chat, Control UI at 1600x900: base shows the alert and logs the three refusals; this branch shows no alert and no refusal, and the first reply arrives.
- Existing consumers: `chat-pane-side-panels.test.ts`, `chat-details-reload.e2e.test.ts`, `test/vitest-ui-e2e-config.test.ts` green. `chat-pane-state-snapshot.e2e.test.ts` was red on `main` and is fixed separately in #203246.
- `pnpm tsgo:ui`, `pnpm check:test-types`, `pnpm check:changed` (the dead-export scan reports two exports in files this PR does not touch; same on `main`).

Isolated Gateway first-send log (fresh agent, real provider, head rebased on #203283): from opening the brand-new chat through the first reply, no FORBIDDEN, UNAVAILABLE or INVALID_REQUEST line. The `talk.catalog` first-read "warming" answer is fixed at its owner in #203283.

## Merge danger

Two-way door: a revert fully restores the previous behavior. No stored state, config or published contract changes. Blast radius: Control UI chats, `talk.catalog` callers for an unstarted main conversation, new operator session rows (pending diff-baseline claim), and session file/diff reads across the first turn.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…w#203126)

## Problem

Open a brand-new main chat (no messages yet, for example right after onboarding sets a model). Session Details shows a red "Session process access changed; refresh the conversation." with Retry until the first reply arrives. The Gateway log shows three refused reads for the same chat:

- `sessions.processes.list` → `FORBIDDEN` "Session process access changed; refresh the conversation."
- `mcp.app.discover` → `FORBIDDEN` "The requested session is unavailable; open an existing session first."
- `talk.catalog` → `INVALID_REQUEST` "No session found: agent:main:main"

A config hot reload is not needed: a fresh profile with a model already configured shows the same three refusals.

![Before: new chat shows the process access alert](https://github.com/user-attachments/assets/da479b13-8826-428d-b009-f85f9c914719)

## Root cause

The agent's main conversation has no session row until its first turn creates it. The chat still starts session-scoped reads for it on open:

- Session Details reads processes as soon as it renders (`ui/src/pages/chat/chat-pane-layout-render.ts:293`, process Details since openclaw#175041). The Gateway has no row to bind the list to and answers with the access-changed error (`src/gateway/server-methods/session-processes.ts:69-79`, since openclaw#164061).
- The composer mounts MCP discovery for the chat. The composer already has a `sessionAdmitted` gate for provisional sessions (`chat-composer-view.tsx:414`, openclaw#166865), but the chat pane never set it. Discovery needs a session authority, which needs a row (`src/gateway/session-access-authority.ts:246`).
- The composer reads the session-scoped Talk catalog. The catalog only uses the key to pick the agent, but `talk.catalog` refused the missing row (`src/gateway/talk/handlers/catalog.ts:536`). Subscriptions already admit the caller's own unstarted main conversation (`isStartableMainSession`, openclaw#197151).

v2026.11.6 has the same chat pane and process code.

## Fix

Each reader is fixed at the owner of the fact it depends on:

| Read | Depends on | Owner and fix |
|---|---|---|
| `sessions.processes.list` | the row's `sessionId` | Control UI: Details stops offering process reads once the chat's history read proved the session absent (`isChatSessionProvenAbsent`, openclaw#197151). A cold load of an existing chat keeps its Details layout while rows load. |
| `mcp.app.discover` | a session authority built from the row | Control UI: the chat pane sets the composer's existing `sessionAdmitted` gate from the selected row, so composer extensions mount once it exists |
| `talk.catalog` | only the agent named by the key | Gateway: answers the caller's own unstarted main conversation from its agent (same `isStartableMainSession` rule as subscriptions); other missing or hidden keys still get "No session found" |

Holding `talk.catalog` in the UI instead would keep dictation unavailable for the first message, and the protocol has no agent-only form of the request.

Same PR, first send (two causes, both at their owner):

- **Diff baseline (session creation owner).** The first turn captures the session diff baseline (`sessionDiffBaseline`, the files that existed before the session) about half a second after `chat.send` creates the row. A diff read in that window either showed pre-existing workspace files as session changes or was refused with "Session workspace changed during file access" when the baseline landed. A new operator conversation now records the pending baseline claim (`sessionDiffBaselineCapture`) with its row, as `sessions.create` already does (`buildNewSessionCreationFields` in `src/config/sessions/session-diff-baseline-capture.ts`), and the diff answers "no changes" while the claim is pending (`src/gateway/server-methods/sessions-diff.ts`). The first turn's existing capture settles the claim.
- **Skill-library selection (workspace owner).** The first turn writes an empty selection (`librarySelections: []`) into a row that had none, and the session file workspace compared `undefined` with `[]` strictly. The sandbox owner already treats both as "no selection" (`librarySelections?.length`); the workspace check now does too.

The existing access-change refusals (replaced row, revoked sharing) are unchanged.

## Impact

- A new chat opens without an error. Processes and MCP controls appear after the first turn, which is when they can have content. The first message can be dictated.
- No protocol or schema change.

![After: new chat opens without the alert](https://github.com/user-attachments/assets/fccbce31-4a42-4e73-a9b5-4f8d0adb2460)

## Evidence

- Real-Gateway Control UI e2e `ui/src/e2e/chat-new-session-readers.real-gateway.e2e.test.ts`: opens `agent:main:main` before its first turn at 1600x900, sends the first message, checks that no non-retryable Gateway read failed and that process, MCP and diff reads succeed after the row exists. Red on the merge base (the three refusals above), green on this branch.
- `src/gateway/talk/handlers/catalog.test.ts` "answers the caller's unstarted main conversation from its agent": red on the merge base, green here. A missing non-main key and a caller who cannot start the conversation still get "No session found".
- `src/gateway/server-methods/sessions-diff-reset.test.ts` "shows no changes for a new operator conversation before its first turn captures the baseline": creates the row through the real reply session init, then reads the diff of a repo with a pre-existing file. Red on the merge base (the pre-existing file is listed as a session change), green here.
- `src/gateway/server-methods/session-file-live-read.test.ts` "keeps a diff read across the first turn recording no library skills": red on the merge base, green here; a real selection change still invalidates.
- Isolated Gateway with a real provider, fresh agent main chat, Control UI at 1600x900: base shows the alert and logs the three refusals; this branch shows no alert and no refusal, and the first reply arrives.
- Existing consumers: `chat-pane-side-panels.test.ts`, `chat-details-reload.e2e.test.ts`, `test/vitest-ui-e2e-config.test.ts` green. `chat-pane-state-snapshot.e2e.test.ts` was red on `main` and is fixed separately in openclaw#203246.
- `pnpm tsgo:ui`, `pnpm check:test-types`, `pnpm check:changed` (the dead-export scan reports two exports in files this PR does not touch; same on `main`).

Isolated Gateway first-send log (fresh agent, real provider, head rebased on openclaw#203283): from opening the brand-new chat through the first reply, no FORBIDDEN, UNAVAILABLE or INVALID_REQUEST line. The `talk.catalog` first-read "warming" answer is fixed at its owner in openclaw#203283.

## Merge danger

Two-way door: a revert fully restores the previous behavior. No stored state, config or published contract changes. Blast radius: Control UI chats, `talk.catalog` callers for an unstarted main conversation, new operator session rows (pending diff-baseline claim), and session file/diff reads across the first turn.

Co-authored-by: Ayaan Zaidi <[email protected]>
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L 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