Skip to content

Commit e71d10f

Browse files
fix(webchat): show manual compaction progress
Add first-class session.operation start/end events for manual compaction and render the existing WebChat compaction indicator from those events. Co-authored-by: Conan Scott <[email protected]>
1 parent f410a95 commit e71d10f

16 files changed

Lines changed: 449 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Docs: https://docs.openclaw.ai
1818
### Fixes
1919

2020
- Gateway/WebChat: route image attachments through a configured vision-capable `imageModel` plan before inlining images, and carry that image-model fallback chain through runtime retries. (#82524) Thanks @frankekn.
21+
- WebChat: show progress while manual `/compact` is running by streaming a session operation event to subscribed Control UI clients. Fixes #82407. Thanks @Conan-Scott.
2122
- Codex app-server: limit canonical OpenAI Codex app-server attribution rewrites to local transcript and trajectory records, leaving runtime/tool routing on the selected OpenAI model metadata so OpenAI API-key backup profiles keep their billing path.
2223
- Android/chat: make bare and markdown URLs in chat messages tappable by preserving Compose URL annotations in rendered markdown. Fixes #82187. (#82392) Thanks @neeravmakwana.
2324
- Plugins/doctor: migrate legacy top-level plugin `tools` declarations into `contracts.tools`, so `openclaw doctor --fix` repairs local plugins for the manifest tool contract. (#81112) Thanks @100yenadmin.

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,44 @@ public struct SessionCompactionCheckpoint: Codable, Sendable {
17881788
}
17891789
}
17901790

1791+
public struct SessionOperationEvent: Codable, Sendable {
1792+
public let operationid: String
1793+
public let operation: String
1794+
public let phase: AnyCodable
1795+
public let sessionkey: String
1796+
public let ts: Int
1797+
public let completed: Bool?
1798+
public let reason: String?
1799+
1800+
public init(
1801+
operationid: String,
1802+
operation: String,
1803+
phase: AnyCodable,
1804+
sessionkey: String,
1805+
ts: Int,
1806+
completed: Bool?,
1807+
reason: String?)
1808+
{
1809+
self.operationid = operationid
1810+
self.operation = operation
1811+
self.phase = phase
1812+
self.sessionkey = sessionkey
1813+
self.ts = ts
1814+
self.completed = completed
1815+
self.reason = reason
1816+
}
1817+
1818+
private enum CodingKeys: String, CodingKey {
1819+
case operationid = "operationId"
1820+
case operation
1821+
case phase
1822+
case sessionkey = "sessionKey"
1823+
case ts
1824+
case completed
1825+
case reason
1826+
}
1827+
}
1828+
17911829
public struct SessionsCompactionListParams: Codable, Sendable {
17921830
public let key: String
17931831

docs/gateway/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ Defaults include isolated state/config and base gateway port `19001`.
317317
a generated dump of every callable helper route.
318318
- Requests: `req(method, params)``res(ok/payload|error)`.
319319
- Common events include `connect.challenge`, `agent`, `chat`,
320-
`session.message`, `session.tool`, `sessions.changed`, `presence`, `tick`,
321-
`health`, `heartbeat`, pairing/approval lifecycle events, and `shutdown`.
320+
`session.message`, `session.operation`, `session.tool`, `sessions.changed`,
321+
`presence`, `tick`, `health`, `heartbeat`, pairing/approval lifecycle events,
322+
and `shutdown`.
322323

323324
Agent runs are two-stage:
324325

docs/gateway/protocol.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,9 @@ enumeration of `src/gateway/server-methods/*.ts`.
473473
events. In protocol v4, delta payloads carry `deltaText`; `message` remains
474474
the cumulative assistant snapshot. Non-prefix replacements set `replace=true`
475475
and use `deltaText` as the replacement text.
476-
- `session.message` and `session.tool`: transcript/event-stream updates for a
477-
subscribed session.
476+
- `session.message`, `session.operation`, and `session.tool`: transcript,
477+
in-flight session operation, and event-stream updates for a subscribed
478+
session.
478479
- `sessions.changed`: session index or metadata changed.
479480
- `presence`: system presence snapshot updates.
480481
- `tick`: periodic keepalive / liveness event.

src/gateway/protocol/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ import {
310310
SessionsCompactionListParamsSchema,
311311
type SessionsCompactionRestoreParams,
312312
SessionsCompactionRestoreParamsSchema,
313+
type SessionOperationEvent,
313314
type SessionsCreateParams,
314315
SessionsCreateParamsSchema,
315316
type SessionsDeleteParams,
@@ -1177,6 +1178,7 @@ export type {
11771178
SessionsPreviewParams,
11781179
SessionsDescribeParams,
11791180
SessionsResolveParams,
1181+
SessionOperationEvent,
11801182
SessionsPatchParams,
11811183
SessionsPatchResult,
11821184
SessionsResetParams,

src/gateway/protocol/schema/protocol-schemas.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ import {
233233
SessionsCompactionRestoreParamsSchema,
234234
SessionsCompactionRestoreResultSchema,
235235
SessionCompactionCheckpointSchema,
236+
SessionOperationEventSchema,
236237
SessionsCleanupParamsSchema,
237238
SessionsCreateParamsSchema,
238239
SessionsDeleteParamsSchema,
@@ -329,6 +330,7 @@ export const ProtocolSchemas = {
329330
SessionsDescribeParams: SessionsDescribeParamsSchema,
330331
SessionsResolveParams: SessionsResolveParamsSchema,
331332
SessionCompactionCheckpoint: SessionCompactionCheckpointSchema,
333+
SessionOperationEvent: SessionOperationEventSchema,
332334
SessionsCompactionListParams: SessionsCompactionListParamsSchema,
333335
SessionsCompactionGetParams: SessionsCompactionGetParamsSchema,
334336
SessionsCompactionBranchParams: SessionsCompactionBranchParamsSchema,

src/gateway/protocol/schema/sessions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ export const SessionCompactionCheckpointReasonSchema = Type.Union([
99
Type.Literal("timeout-retry"),
1010
]);
1111

12+
export const SessionOperationEventSchema = Type.Object(
13+
{
14+
operationId: NonEmptyString,
15+
operation: Type.Literal("compact"),
16+
phase: Type.Union([Type.Literal("start"), Type.Literal("end")]),
17+
sessionKey: NonEmptyString,
18+
ts: Type.Integer({ minimum: 0 }),
19+
completed: Type.Optional(Type.Boolean()),
20+
reason: Type.Optional(Type.String()),
21+
},
22+
{ additionalProperties: false },
23+
);
24+
1225
export const SessionCompactionTranscriptReferenceSchema = Type.Object(
1326
{
1427
sessionId: NonEmptyString,

src/gateway/protocol/schema/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export type SessionsPreviewParams = SchemaType<"SessionsPreviewParams">;
5555
export type SessionsDescribeParams = SchemaType<"SessionsDescribeParams">;
5656
export type SessionsResolveParams = SchemaType<"SessionsResolveParams">;
5757
export type SessionCompactionCheckpoint = SchemaType<"SessionCompactionCheckpoint">;
58+
export type SessionOperationEvent = SchemaType<"SessionOperationEvent">;
5859
export type SessionsCompactionListParams = SchemaType<"SessionsCompactionListParams">;
5960
export type SessionsCompactionGetParams = SchemaType<"SessionsCompactionGetParams">;
6061
export type SessionsCompactionBranchParams = SchemaType<"SessionsCompactionBranchParams">;

src/gateway/server-broadcast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const EVENT_SCOPE_GUARDS: Record<string, string[]> = {
4343
"node.pair.resolved": [PAIRING_SCOPE],
4444
"sessions.changed": [READ_SCOPE],
4545
"session.message": [READ_SCOPE],
46+
"session.operation": [READ_SCOPE],
4647
"session.tool": [READ_SCOPE],
4748
};
4849

src/gateway/server-methods-list.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const GATEWAY_EVENTS = [
3434
"agent",
3535
"chat",
3636
"session.message",
37+
"session.operation",
3738
"session.tool",
3839
"sessions.changed",
3940
"presence",

0 commit comments

Comments
 (0)