Skip to content

Commit edb5adf

Browse files
jesse-merhiJesse Merhi
andauthored
Start new sessions with folder group defaults (#123276)
* feat(ui): add folder group session defaults * fix(ci): align folder group contracts * fix(protocol): refresh Android gateway methods * fix(ui): reuse folder picker for group defaults * fix(ui): harden session group defaults * test(ui): align group defaults with current main * test(ui): keep group catalog defaults path-free * fix(ui): close folder group CI gaps * fix(ui): satisfy folder group CI contracts * fix(session-groups): enforce defaults safety * test(gateway): keep group defaults in workspace * fix(session-groups): enforce defaults participation * fix(session-groups): close review authorization races * fix(session-groups): canonicalize defaults authorization --------- Co-authored-by: Jesse Merhi <[email protected]> Co-authored-by: Jesse Merhi <[email protected]>
1 parent 2ee5c2f commit edb5adf

80 files changed

Lines changed: 3446 additions & 313 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,10 @@ enum class GatewayMethod(
406406
SessionsDelete("sessions.delete"),
407407
SessionsCompact("sessions.compact"),
408408
SessionsGroupsList("sessions.groups.list"),
409+
SessionsGroupsDefaults("sessions.groups.defaults"),
409410
SessionsGroupsPut("sessions.groups.put"),
410411
SessionsGroupsRename("sessions.groups.rename"),
412+
SessionsGroupsUpdate("sessions.groups.update"),
411413
SessionsGroupsDelete("sessions.groups.delete"),
412414
LastHeartbeat("last-heartbeat"),
413415
SetHeartbeats("set-heartbeats"),

‎apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8437,6 +8437,7 @@ public struct SessionsCreateParams: Codable, Sendable {
84378437
public let key: String?
84388438
public let agentid: String?
84398439
public let label: String?
8440+
public let category: String?
84408441
public let model: String?
84418442
public let thinkinglevel: String?
84428443
public let incognito: Bool?
@@ -8462,6 +8463,7 @@ public struct SessionsCreateParams: Codable, Sendable {
84628463
key: String? = nil,
84638464
agentid: String? = nil,
84648465
label: String? = nil,
8466+
category: String? = nil,
84658467
model: String? = nil,
84668468
thinkinglevel: String? = nil,
84678469
incognito: Bool? = nil,
@@ -8486,6 +8488,7 @@ public struct SessionsCreateParams: Codable, Sendable {
84868488
self.key = key
84878489
self.agentid = agentid
84888490
self.label = label
8491+
self.category = category
84898492
self.model = model
84908493
self.thinkinglevel = thinkinglevel
84918494
self.incognito = incognito
@@ -8512,6 +8515,7 @@ public struct SessionsCreateParams: Codable, Sendable {
85128515
case key
85138516
case agentid = "agentId"
85148517
case label
8518+
case category
85158519
case model
85168520
case thinkinglevel = "thinkingLevel"
85178521
case incognito
@@ -9217,6 +9221,28 @@ public struct SessionGroup: Codable, Sendable {
92179221
}
92189222
}
92199223

9224+
public struct SessionGroupDefaults: Codable, Sendable {
9225+
public let name: String
9226+
public let cwd: String?
9227+
public let worktree: Bool?
9228+
9229+
public init(
9230+
name: String,
9231+
cwd: String? = nil,
9232+
worktree: Bool? = nil)
9233+
{
9234+
self.name = name
9235+
self.cwd = cwd
9236+
self.worktree = worktree
9237+
}
9238+
9239+
private enum CodingKeys: String, CodingKey {
9240+
case name
9241+
case cwd
9242+
case worktree
9243+
}
9244+
}
9245+
92209246
public struct SessionsGroupsListParams: Codable, Sendable {}
92219247

92229248
public struct SessionsGroupsListResult: Codable, Sendable {
@@ -9237,6 +9263,22 @@ public struct SessionsGroupsListResult: Codable, Sendable {
92379263
}
92389264
}
92399265

9266+
public struct SessionsGroupsDefaultsParams: Codable, Sendable {}
9267+
9268+
public struct SessionsGroupsDefaultsResult: Codable, Sendable {
9269+
public let defaults: [SessionGroupDefaults]
9270+
9271+
public init(
9272+
defaults: [SessionGroupDefaults])
9273+
{
9274+
self.defaults = defaults
9275+
}
9276+
9277+
private enum CodingKeys: String, CodingKey {
9278+
case defaults
9279+
}
9280+
}
9281+
92409282
public struct SessionsGroupsPutParams: Codable, Sendable {
92419283
public let names: [String]
92429284
public let sectionorder: [String]?
@@ -9273,6 +9315,46 @@ public struct SessionsGroupsRenameParams: Codable, Sendable {
92739315
}
92749316
}
92759317

9318+
public struct SessionsGroupsUpdateParams: Codable, Sendable {
9319+
public let name: String
9320+
public let cwd: AnyCodable
9321+
public let worktree: Bool
9322+
9323+
public init(
9324+
name: String,
9325+
cwd: AnyCodable,
9326+
worktree: Bool)
9327+
{
9328+
self.name = name
9329+
self.cwd = cwd
9330+
self.worktree = worktree
9331+
}
9332+
9333+
private enum CodingKeys: String, CodingKey {
9334+
case name
9335+
case cwd
9336+
case worktree
9337+
}
9338+
}
9339+
9340+
public struct SessionsGroupsUpdateResult: Codable, Sendable {
9341+
public let ok: Bool
9342+
public let defaults: [SessionGroupDefaults]
9343+
9344+
public init(
9345+
ok: Bool,
9346+
defaults: [SessionGroupDefaults])
9347+
{
9348+
self.ok = ok
9349+
self.defaults = defaults
9350+
}
9351+
9352+
private enum CodingKeys: String, CodingKey {
9353+
case ok
9354+
case defaults
9355+
}
9356+
}
9357+
92769358
public struct SessionsGroupsDeleteParams: Codable, Sendable {
92779359
public let name: String
92789360

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"startupJsGzipBytes": 333338,
3-
"reason": "cumulative 2026-08-15 UI fix growth (tab retry/session attention/talk backpressure stream) plus chat transcript virtualizer re-attach fix (#123974); CI runs 31861213699 and 31861214469 build-artifacts bytes",
2+
"startupJsGzipBytes": 334391,
3+
"reason": "cumulative 2026-08-15 UI growth plus folder group defaults catalog and lazy New Session route resolution",
44
"updatedAt": "2026-08-15"
55
}

‎docs/gateway/protocol.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,9 @@ methods. Treat this as feature discovery, not a full enumeration of
649649
- `sessions.preview` returns bounded transcript previews for specific session keys.
650650
- `sessions.describe` returns one gateway session row for an exact session key.
651651
- `sessions.resolve` resolves or canonicalizes a session target by key, raw session ID, label, or Control UI short ID. Ambiguous short IDs return a bounded candidate list as a successful RPC result.
652-
- `sessions.create` creates a new session entry. Optional `model` and `thinkingLevel` values persist the initial model and reasoning overrides atomically. `worktree: true` provisions a managed worktree; optional `worktreeBaseRef`/`worktreeName` select the base ref and branch name, and `execNode` (`operator.admin`) binds session exec to a node host. Without `worktreeName`, OpenClaw derives a readable name from the session label or generated first-message title, then falls back to a crustacean-themed name; names already occupied by another owner, local branch, or unmanaged path receive a numeric suffix. The created worktree is echoed in the result and persisted on the session row (`worktree: { id, branch, repoRoot }`). When the entry is created but its nested initial `chat.send` is rejected, the successful result includes `runStarted: false` and `runError`; clients can preserve the prompt and retry against the returned session key. A caller that passes `parentSessionKey` with `emitCommandHooks: true` should also declare the lifecycle disposition of a distinct child: `succeedsParent: true` ends the parent with `session_end`, while `false` keeps the parent active and emits only the child's `session_start`. Omitting `succeedsParent` preserves the legacy parent-rollover behavior for existing clients. The disposition requires both parent linkage and command hooks; a fork cannot succeed its parent. Main-session reset-in-place behavior is unchanged because no distinct child is created. New rows are stamped with write-once creation provenance (`createdVia`, `createdActor`, `createdAt`) from the trusted creation seam; adopting an existing key never restamps it. For human profile actors, `createdActor.label` is resolved from the current user profile when the row is projected and is never stored on the session entry, so profile renames do not drift. Session rows also carry `parentSessionKey` (navigation parent, persisted), `controlOwnerSessionKey` (runtime controller when live), `forkSource` (exact source key + transcript generation for forks), and `previousSessionId` (prior transcript generation under the same key).
652+
- `sessions.create` creates a new session entry. Optional `model` and `thinkingLevel` values persist the initial model and reasoning overrides atomically; optional `category` assigns the session to a custom group and registers that group when first used. `worktree: true` provisions a managed worktree; optional `worktreeBaseRef`/`worktreeName` select the base ref and branch name, and `execNode` (`operator.admin`) binds session exec to a node host. Without `worktreeName`, OpenClaw derives a readable name from the session label or generated first-message title, then falls back to a crustacean-themed name; names already occupied by another owner, local branch, or unmanaged path receive a numeric suffix. The created worktree is echoed in the result and persisted on the session row (`worktree: { id, branch, repoRoot }`). When the entry is created but its nested initial `chat.send` is rejected, the successful result includes `runStarted: false` and `runError`; clients can preserve the prompt and retry against the returned session key. A caller that passes `parentSessionKey` with `emitCommandHooks: true` should also declare the lifecycle disposition of a distinct child: `succeedsParent: true` ends the parent with `session_end`, while `false` keeps the parent active and emits only the child's `session_start`. Omitting `succeedsParent` preserves the legacy parent-rollover behavior for existing clients. The disposition requires both parent linkage and command hooks; a fork cannot succeed its parent. Main-session reset-in-place behavior is unchanged because no distinct child is created. New rows are stamped with write-once creation provenance (`createdVia`, `createdActor`, `createdAt`) from the trusted creation seam; adopting an existing key never restamps it. For human profile actors, `createdActor.label` is resolved from the current user profile when the row is projected and is never stored on the session entry, so profile renames do not drift. Session rows also carry `parentSessionKey` (navigation parent, persisted), `controlOwnerSessionKey` (runtime controller when live), `forkSource` (exact source key + transcript generation for forks), and `previousSessionId` (prior transcript generation under the same key).
653653
- `sessions.dispatch` (`operator.admin`) moves an existing local OpenClaw session with a live, registry-owned session managed worktree to a configured cloud-worker profile. Pass `{ key, profileId, agentId? }`. The Gateway does not advertise the method when no worker profile is configured. Dispatch closes local turn admission before draining active work and returns only after placement reaches `active` worker ownership. Arbitrary plain directories are not dispatchable; after admission, the workspace transport may use manifest mirroring if the managed worktree's Git metadata later becomes unavailable. SSH fallback candidates rotate only for idempotent probes, content-addressed transfers, receipt/lock-guarded artifact installation, convergent managed-worktree mirroring, and tunnel reconnects. Ambiguous unguarded stateful commands fail closed and are not replayed. Dispatch is one-way; worker-to-local pull-back is not part of this RPC.
654-
- `sessions.groups.list`, `sessions.groups.put`, `sessions.groups.rename`, and `sessions.groups.delete` manage the gateway-owned custom session group catalog (names + display order). Membership stays on each session's `category` field; rename and delete update member sessions server-side.
654+
- `sessions.groups.list`, `sessions.groups.put`, `sessions.groups.rename`, and `sessions.groups.delete` manage the gateway-owned custom session group catalog (names + display order). The read-scoped list result is intentionally path-free. `sessions.groups.defaults` and `sessions.groups.update` require `operator.write` and read or replace one custom group's optional working-directory and worktree defaults. Non-admin callers can save only directories inside a configured agent workspace; other absolute Gateway paths require `operator.admin`. Membership stays on each session's `category` field; rename and delete update member sessions server-side.
655655
- `sessions.send` sends a message into an existing session.
656656
- `sessions.steer` is the interrupt-and-steer variant for an active session.
657657
- `sessions.abort` aborts active work for a session. Pass `key` plus optional `runId`, or `runId` alone for active runs the gateway can resolve to a session. Supplying `runId` keeps cancellation scoped to that run. Set `clearQueued: true` on a key-only non-global request to also discard followup and lane queues owned by that session. Existing callers that omit `clearQueued` preserve those queues. The literal `global` key keeps the existing agent-qualified `chat.abort` ownership rules and does not perform non-global followup or lane cleanup.

‎docs/platforms/mac/webchat.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Disable the feature entirely with **Settings → General → Quick Chat**; the s
9696
- Data plane: Gateway WS methods `chat.history`, `chat.message.get`, `chat.send`, `chat.abort`, `chat.inject`, plus `question.list` and `question.resolve`, and events `chat`, `agent`, `presence`, `tick`, `health`; question cards follow `question.requested` and `question.resolved` events and refresh from `question.list` after reconnects.
9797
- `chat.history` returns a display-normalized transcript: inline directive tags are stripped from visible text, plain-text tool-call XML payloads (`<tool_call>`, `<function_call>`, `<tool_calls>`, `<function_calls>`, including truncated blocks) and leaked model control tokens are stripped, pure silent-token assistant rows such as exact `NO_REPLY`/`no_reply` are omitted, and oversized rows can be replaced with a truncated placeholder.
9898
- Session: defaults to the primary session as above; the UI can switch between sessions.
99-
- Session groups: `sessions.groups.list`, `sessions.groups.put`, `sessions.groups.rename`, and `sessions.groups.delete` own the group catalog. Membership is the session `category` updated through `sessions.patch`.
99+
- Session groups: `sessions.groups.list`, `sessions.groups.put`, `sessions.groups.rename`, and `sessions.groups.delete` own the path-free group catalog. Write-scoped `sessions.groups.defaults` and `sessions.groups.update` own optional New Session folder/worktree defaults. Membership is the session `category` updated through `sessions.patch` or assigned during `sessions.create`.
100100
- Unread state: after a session activates and its live history loads successfully, the app clears that session's unread marker. Failed history loads do not clear it; a transient patch failure retries on the next activation.
101101
- Onboarding uses a dedicated session to keep first-run setup separate.
102102
- Offline cache: the app keeps a small read-only cache of recent chat sessions and transcripts per gateway (`~/Library/Application Support/OpenClaw/chat-cache.sqlite`): cold opens paint the last known transcript immediately and refresh once the Gateway responds, and recent chats stay browsable while disconnected (sending stays disabled until the connection is back).

0 commit comments

Comments
 (0)