GeezerVison is showing github.com — fix(protocol): accept idle in the message type filter (#56504) · anomalyco/opencode@c38d83c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/api/api.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1371,6 +1371,7 @@ export type MessageListInput = { | 1371 | 1371 | | "shell" | 1372 | 1372 | | "assistant" | 1373 | 1373 | | "compaction" | | 1374 | + | "idle" | 1374 | 1375 | | undefined | 1375 | 1376 | } | 1376 | 1377 | export type MessageListOutput = { | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/types.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5706,6 +5706,7 @@ export type MessageListInput = { | 5706 | 5706 | | "shell" | 5707 | 5707 | | "assistant" | 5708 | 5708 | | "compaction" | | 5709 | + | "idle" | 5709 | 5710 | | undefined | 5710 | 5711 | }["limit"] | 5711 | 5712 | readonly order?: { | @@ -5723,6 +5724,7 @@ export type MessageListInput = { | 5723 | 5724 | | "shell" | 5724 | 5725 | | "assistant" | 5725 | 5726 | | "compaction" | | 5727 | + | "idle" | 5726 | 5728 | | undefined | 5727 | 5729 | }["order"] | 5728 | 5730 | readonly cursor?: { | @@ -5740,6 +5742,7 @@ export type MessageListInput = { | 5740 | 5742 | | "shell" | 5741 | 5743 | | "assistant" | 5742 | 5744 | | "compaction" | | 5745 | + | "idle" | 5743 | 5746 | | undefined | 5744 | 5747 | }["cursor"] | 5745 | 5748 | readonly type?: { | @@ -5757,6 +5760,7 @@ export type MessageListInput = { | 5757 | 5760 | | "shell" | 5758 | 5761 | | "assistant" | 5759 | 5762 | | "compaction" | | 5763 | + | "idle" | 5760 | 5764 | | undefined | 5761 | 5765 | }["type"] | 5762 | 5766 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/protocol/openapi.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 4976 | 4976 | "skill", | 4977 | 4977 | "shell", | 4978 | 4978 | "assistant", | 4979 | | - "compaction" | | 4979 | + "compaction", | | 4980 | + "idle" | 4980 | 4981 | ] | 4981 | 4982 | }, | 4982 | 4983 | { | |
Collapse file Copy file name to clipboardExpand all lines: packages/protocol/src/groups/message.ts +16-14Lines changed: 16 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -5,6 +5,21 @@ import { Schema, Struct } from "effect" | 5 | 5 | import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/http-api" | 6 | 6 | import { InvalidCursorError, SessionNotFoundError, UnknownError } from "../errors.js" | 7 | 7 |
| | 8 | +// Keyed by message type so a new message type cannot be left out of the filter. | | 9 | +const MessageTypes = { | | 10 | + "agent-switched": true, | | 11 | + "model-switched": true, | | 12 | + "location-switched": true, | | 13 | + user: true, | | 14 | + synthetic: true, | | 15 | + system: true, | | 16 | + skill: true, | | 17 | + shell: true, | | 18 | + assistant: true, | | 19 | + compaction: true, | | 20 | + idle: true, | | 21 | +} satisfies Record<SessionMessage.Type, true> | | 22 | + | 8 | 23 | export const SessionMessagesQuery = Schema.Struct({ | 9 | 24 | limit: Schema.optional( | 10 | 25 | Schema.NumberFromString.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(1), Schema.isLessThanOrEqualTo(200)), | @@ -20,20 +35,7 @@ export const SessionMessagesQuery = Schema.Struct({ | 20 | 35 | "Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.", | 21 | 36 | }), | 22 | 37 | ), | 23 | | - type: Schema.optional( | 24 | | - Schema.Literals([ | 25 | | - "agent-switched", | 26 | | - "model-switched", | 27 | | - "location-switched", | 28 | | - "user", | 29 | | - "synthetic", | 30 | | - "system", | 31 | | - "skill", | 32 | | - "shell", | 33 | | - "assistant", | 34 | | - "compaction", | 35 | | - ] satisfies ReadonlyArray<SessionMessage.Type>), | 36 | | - ).annotate({ | | 38 | + type: Schema.optional(Schema.Literals(Object.keys(MessageTypes) as ReadonlyArray<SessionMessage.Type>)).annotate({ | 37 | 39 | description: | 38 | 40 | "Filter by message type before pagination. When omitted, all message types are returned. Pass the same type when following cursors.", | 39 | 41 | }), | |
Collapse file Copy file name to clipboardExpand all lines: packages/server/test/message.test.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ const messages: SessionMessageInfo[] = [ | 30 | 30 | { id: "msg_x", type: "user", text: "Third request", time: { created: 600 } }, | 31 | 31 | { id: "msg_system", type: "system", text: "Updated instructions", time: { created: 800 } }, | 32 | 32 | { id: "msg_a", type: "user", text: "Fourth request", time: { created: 500 } }, | | 33 | + { id: "msg_idle", type: "idle", outcome: "succeeded", time: { created: 900 } }, | 33 | 34 | ] | 34 | 35 |
| 35 | 36 | const setup = Effect.gen(function* () { | @@ -81,6 +82,9 @@ it.live("filters message types before paginating in either direction through the | 81 | 82 | expect( | 82 | 83 | (await fixture.api.message.list({ sessionID: fixture.sessionID, type: "assistant", limit: 1 })).data, | 83 | 84 | ).toEqual([messages[1]]) | | 85 | + expect((await fixture.api.message.list({ sessionID: fixture.sessionID, type: "idle" })).data).toEqual([ | | 86 | + messages[8], | | 87 | + ]) | 84 | 88 | expect((await fixture.api.message.list({ sessionID: fixture.sessionID, type: "shell" })).data).toEqual([]) | 85 | 89 | }) | 86 | 90 | }), | |
Collapse file Copy file name to clipboardExpand all lines: services/www/openapi.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 4976 | 4976 | "skill", | 4977 | 4977 | "shell", | 4978 | 4978 | "assistant", | 4979 | | - "compaction" | | 4979 | + "compaction", | | 4980 | + "idle" | 4980 | 4981 | ] | 4981 | 4982 | }, | 4982 | 4983 | { | |
Collapse file Copy file name to clipboardExpand all lines: services/www/public/openapi.json +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 4976 | 4976 | "skill", | 4977 | 4977 | "shell", | 4978 | 4978 | "assistant", | 4979 | | - "compaction" | | 4979 | + "compaction", | | 4980 | + "idle" | 4980 | 4981 | ] | 4981 | 4982 | }, | 4982 | 4983 | { | |
|