GeezerVison is showing github.com — refactor(session): remove message content mutation API (#48043) · jinhuang712/opencode@43f5414
This repository was archived by the owner on Oct 29, 2026. It is now read-only.
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 +12-25Lines changed: 12 additions & 25 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1033,32 +1033,32 @@ export type SessionLogOutput = | 1033 | 1033 | readonly id: Event.ID | 1034 | 1034 | readonly created: number | 1035 | 1035 | readonly metadata?: { readonly [x: string]: unknown } | undefined | 1036 | | - readonly type: "session.message.content.updated" | | 1036 | + readonly type: "session.usage.recorded" | 1037 | 1037 | readonly durable: { readonly aggregateID: string; readonly seq: Event.Seq; readonly version: Event.Version } | 1038 | 1038 | readonly location?: Location.Ref | undefined | 1039 | 1039 | readonly data: { | 1040 | 1040 | readonly sessionID: Session.ID | 1041 | | - readonly messageID: SessionMessage.ID | 1042 | | - readonly content: ReadonlyArray<SessionMessage.AssistantContentEncoded> | | 1041 | + readonly source: "title" | "compaction" | | 1042 | + readonly cost: number & Brand.Brand<"Money.USD"> | | 1043 | + readonly tokens: { | | 1044 | + readonly input: number | | 1045 | + readonly output: number | | 1046 | + readonly reasoning: number | | 1047 | + readonly cache: { readonly read: number; readonly write: number } | | 1048 | + } | 1043 | 1049 | } | 1044 | 1050 | } | 1045 | 1051 | | { | 1046 | 1052 | readonly id: Event.ID | 1047 | 1053 | readonly created: number | 1048 | 1054 | readonly metadata?: { readonly [x: string]: unknown } | undefined | 1049 | | - readonly type: "session.usage.recorded" | | 1055 | + readonly type: "session.message.content.updated" | 1050 | 1056 | readonly durable: { readonly aggregateID: string; readonly seq: Event.Seq; readonly version: Event.Version } | 1051 | 1057 | readonly location?: Location.Ref | undefined | 1052 | 1058 | readonly data: { | 1053 | 1059 | readonly sessionID: Session.ID | 1054 | | - readonly source: "title" | "compaction" | 1055 | | - readonly cost: number & Brand.Brand<"Money.USD"> | 1056 | | - readonly tokens: { | 1057 | | - readonly input: number | 1058 | | - readonly output: number | 1059 | | - readonly reasoning: number | 1060 | | - readonly cache: { readonly read: number; readonly write: number } | 1061 | | - } | | 1060 | + readonly messageID: SessionMessage.ID | | 1061 | + readonly content: ReadonlyArray<SessionMessage.AssistantContentEncoded> | 1062 | 1062 | } | 1063 | 1063 | } | 1064 | 1064 | ) | @@ -1081,18 +1081,6 @@ export type SessionMessageInput = { readonly sessionID: Session.ID; readonly mes | 1081 | 1081 | export type SessionMessageOutput = SessionMessage.Info | 1082 | 1082 | export type SessionMessageOperation<E = never> = (input: SessionMessageInput) => Effect.Effect<SessionMessageOutput, E> | 1083 | 1083 |
| 1084 | | -export type SessionMessageUpdateInput = { | 1085 | | - readonly sessionID: Session.ID | 1086 | | - readonly messageID: SessionMessage.ID | 1087 | | - readonly content: ReadonlyArray< | 1088 | | - SessionMessage.AssistantText | SessionMessage.AssistantReasoning | SessionMessage.AssistantTool | 1089 | | - > | 1090 | | -} | 1091 | | -export type SessionMessageUpdateOutput = SessionMessage.Assistant | 1092 | | -export type SessionMessageUpdateOperation<E = never> = ( | 1093 | | - input: SessionMessageUpdateInput, | 1094 | | -) => Effect.Effect<SessionMessageUpdateOutput, E> | 1095 | | - | 1096 | 1084 | export type SessionEnvironmentInput = { | 1097 | 1085 | readonly sessionID: Session.ID | 1098 | 1086 | readonly variables: { readonly [x: string]: string } | @@ -1151,7 +1139,6 @@ export interface SessionApi<E = never> { | 1151 | 1139 | readonly interrupt: SessionInterruptOperation<E> | 1152 | 1140 | readonly background: SessionBackgroundOperation<E> | 1153 | 1141 | readonly message: SessionMessageOperation<E> | 1154 | | - readonly messageUpdate: SessionMessageUpdateOperation<E> | 1155 | 1142 | readonly environment: SessionEnvironmentOperation<E> | 1156 | 1143 | readonly view: SessionViewOperation<E> | 1157 | 1144 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/effect/generated/client.ts -14Lines changed: 0 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,8 +92,6 @@ import type { | 92 | 92 | SessionBackgroundOutput, | 93 | 93 | SessionMessageInput, | 94 | 94 | SessionMessageOutput, | 95 | | - SessionMessageUpdateInput, | 96 | | - SessionMessageUpdateOutput, | 97 | 95 | SessionEnvironmentInput, | 98 | 96 | SessionEnvironmentOutput, | 99 | 97 | SessionViewInput, | @@ -691,17 +689,6 @@ const EndpointSessionMessage = (raw: RawClient["server.session"]) => (input: Ses | 691 | 689 | ), | 692 | 690 | ) | 693 | 691 |
| 694 | | -const EndpointSessionMessageUpdate = (raw: RawClient["server.session"]) => (input: SessionMessageUpdateInput) => | 695 | | - preserveEffect<SessionMessageUpdateOutput>()( | 696 | | - raw["session.messageUpdate"]({ | 697 | | - params: { sessionID: input["sessionID"], messageID: input["messageID"] }, | 698 | | - payload: { content: input["content"] }, | 699 | | - }).pipe( | 700 | | - Effect.mapError(mapClientError), | 701 | | - Effect.map((value) => value.data), | 702 | | - ), | 703 | | - ) | 704 | | - | 705 | 692 | const EndpointSessionEnvironment = (raw: RawClient["server.session"]) => (input: SessionEnvironmentInput) => | 706 | 693 | preserveEffect<SessionEnvironmentOutput>()( | 707 | 694 | raw["session.environment"]({ | @@ -762,7 +749,6 @@ const adaptGroupSession = (raw: RawClient["server.session"]) => ({ | 762 | 749 | interrupt: EndpointSessionInterrupt(raw), | 763 | 750 | background: EndpointSessionBackground(raw), | 764 | 751 | message: EndpointSessionMessage(raw), | 765 | | - messageUpdate: EndpointSessionMessageUpdate(raw), | 766 | 752 | environment: EndpointSessionEnvironment(raw), | 767 | 753 | view: EndpointSessionView(raw), | 768 | 754 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/client.ts -14Lines changed: 0 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -86,8 +86,6 @@ import type { | 86 | 86 | SessionBackgroundOutput, | 87 | 87 | SessionMessageInput, | 88 | 88 | SessionMessageOutput, | 89 | | - SessionMessageUpdateInput, | 90 | | - SessionMessageUpdateOutput, | 91 | 89 | SessionEnvironmentInput, | 92 | 90 | SessionEnvironmentOutput, | 93 | 91 | SessionViewInput, | @@ -986,18 +984,6 @@ export function make(options: ClientOptions) { | 986 | 984 | }, | 987 | 985 | requestOptions, | 988 | 986 | ).then((value) => value.data), | 989 | | - messageUpdate: (input: SessionMessageUpdateInput, requestOptions?: RequestOptions) => | 990 | | - request<{ readonly data: SessionMessageUpdateOutput }>( | 991 | | - { | 992 | | - method: "PATCH", | 993 | | - path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`, | 994 | | - body: { content: input["content"] }, | 995 | | - successStatus: 200, | 996 | | - declaredStatuses: [400, 401, 404, 409], | 997 | | - empty: false, | 998 | | - }, | 999 | | - requestOptions, | 1000 | | - ).then((value) => value.data), | 1001 | 987 | environment: (input: SessionEnvironmentInput, requestOptions?: RequestOptions) => | 1002 | 988 | request<SessionEnvironmentOutput>( | 1003 | 989 | { | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/promise/generated/types.ts +1-87Lines changed: 1 addition & 87 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2252,8 +2252,8 @@ export type SessionEventDurable = | 2252 | 2252 | | SessionRevertStaged | 2253 | 2253 | | SessionRevertCleared | 2254 | 2254 | | SessionRevertCommitted | 2255 | | - | SessionMessageContentUpdated | 2256 | 2255 | | SessionUsageRecorded | | 2256 | + | SessionMessageContentUpdated | 2257 | 2257 |
| 2258 | 2258 | export type IntegrationInfo = { | 2259 | 2259 | id: string | @@ -2317,7 +2317,6 @@ export type V2Event = | 2317 | 2317 | | SessionRevertStaged | 2318 | 2318 | | SessionRevertCleared | 2319 | 2319 | | SessionRevertCommitted | 2320 | | - | SessionMessageContentUpdated | 2321 | 2320 | | FilesystemChanged | 2322 | 2321 | | ReferenceUpdated | 2323 | 2322 | | PermissionAsked | @@ -4270,91 +4269,6 @@ export type SessionMessageInput = { | 4270 | 4269 |
| 4271 | 4270 | export type SessionMessageOutput = { data: SessionMessageInfo }["data"] | 4272 | 4271 |
| 4273 | | -export type SessionMessageUpdateInput = { | 4274 | | - readonly sessionID: { readonly sessionID: string; readonly messageID: string }["sessionID"] | 4275 | | - readonly messageID: { readonly sessionID: string; readonly messageID: string }["messageID"] | 4276 | | - readonly content: { | 4277 | | - readonly content: ReadonlyArray< | 4278 | | - | { readonly type: "text"; readonly text: string; readonly state?: { readonly [x: string]: JsonValue } } | 4279 | | - | { | 4280 | | - readonly type: "reasoning" | 4281 | | - readonly text: string | 4282 | | - readonly state?: { readonly [x: string]: JsonValue } | 4283 | | - readonly time?: { readonly created: number; readonly completed?: number } | 4284 | | - } | 4285 | | - | { | 4286 | | - readonly type: "tool" | 4287 | | - readonly id: string | 4288 | | - readonly name: string | 4289 | | - readonly executed?: boolean | 4290 | | - readonly providerState?: { readonly [x: string]: JsonValue } | 4291 | | - readonly providerResultState?: { readonly [x: string]: JsonValue } | 4292 | | - readonly state: | 4293 | | - | { readonly status: "streaming"; readonly input: string } | 4294 | | - | { | 4295 | | - readonly status: "running" | 4296 | | - readonly input: { readonly [x: string]: JsonValue } | 4297 | | - readonly metadata: { readonly [x: string]: JsonValue } | 4298 | | - } | 4299 | | - | { | 4300 | | - readonly status: "completed" | 4301 | | - readonly input: { readonly [x: string]: JsonValue } | 4302 | | - readonly content: readonly [ | 4303 | | - ( | 4304 | | - | { readonly type: "text"; readonly text: string } | 4305 | | - | { | 4306 | | - readonly type: "file" | 4307 | | - readonly uri: string | 4308 | | - readonly mime: string | 4309 | | - readonly name?: string | null | 4310 | | - } | 4311 | | - ), | 4312 | | - ...Array< | 4313 | | - | { readonly type: "text"; readonly text: string } | 4314 | | - | { | 4315 | | - readonly type: "file" | 4316 | | - readonly uri: string | 4317 | | - readonly mime: string | 4318 | | - readonly name?: string | null | 4319 | | - } | 4320 | | - >, | 4321 | | - ] | 4322 | | - readonly metadata?: { readonly [x: string]: JsonValue } | 4323 | | - } | 4324 | | - | { | 4325 | | - readonly status: "error" | 4326 | | - readonly input: { readonly [x: string]: JsonValue } | 4327 | | - readonly error: { readonly type: string; readonly message: string; readonly status?: number } | 4328 | | - readonly content?: readonly [ | 4329 | | - ( | 4330 | | - | { readonly type: "text"; readonly text: string } | 4331 | | - | { | 4332 | | - readonly type: "file" | 4333 | | - readonly uri: string | 4334 | | - readonly mime: string | 4335 | | - readonly name?: string | null | 4336 | | - } | 4337 | | - ), | 4338 | | - ...Array< | 4339 | | - | { readonly type: "text"; readonly text: string } | 4340 | | - | { | 4341 | | - readonly type: "file" | 4342 | | - readonly uri: string | 4343 | | - readonly mime: string | 4344 | | - readonly name?: string | null | 4345 | | - } | 4346 | | - >, | 4347 | | - ] | 4348 | | - readonly metadata?: { readonly [x: string]: JsonValue } | 4349 | | - } | 4350 | | - readonly time: { readonly created: number; readonly ran?: number; readonly completed?: number } | 4351 | | - } | 4352 | | - > | 4353 | | - }["content"] | 4354 | | -} | 4355 | | - | 4356 | | -export type SessionMessageUpdateOutput = { data: SessionMessageAssistant }["data"] | 4357 | | - | 4358 | 4272 | export type SessionEnvironmentInput = { | 4359 | 4273 | readonly sessionID: { readonly sessionID: string }["sessionID"] | 4360 | 4274 | readonly variables: { readonly variables: { readonly [x: string]: string } }["variables"] | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/src/solid/data.ts -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -827,16 +827,6 @@ export function createData(config: CreateDataInput) { | 827 | 827 | match.time.completed = event.created | 828 | 828 | }) | 829 | 829 | return | 830 | | - case "session.message.content.updated": { | 831 | | - if (store.session.message[event.data.sessionID]) | 832 | | - message.editAssistant(event.data.sessionID, event.data.messageID, (assistant) => { | 833 | | - assistant.content = [...event.data.content] | 834 | | - }) | 835 | | - if (!sync.pending(`session.message:${event.data.sessionID}`)) return | 836 | | - result.session.message.invalidate(event.data.sessionID) | 837 | | - refresh(() => result.session.message.sync(event.data.sessionID)) | 838 | | - return | 839 | | - } | 840 | 830 | case "session.step.started": | 841 | 831 | message.update(event.data.sessionID, (draft, index) => { | 842 | 832 | const position = index.get(event.data.assistantMessageID) | |
Collapse file Copy file name to clipboardExpand all lines: packages/client/test/solid-data.test.ts -71Lines changed: 0 additions & 71 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -744,77 +744,6 @@ test.each(["success", "failure", "cancel", "cancel-retry", "cancel-page", "join- | 744 | 744 | }, | 745 | 745 | ) | 746 | 746 |
| 747 | | -test("preserves assistant content replacement events across an active message read", async () => { | 748 | | - const listeners = new Set<Parameters<CreateDataInput["event"]["listen"]>[0]>() | 749 | | - const release = Promise.withResolvers<void>() | 750 | | - let requests = 0 | 751 | | - const content = [ | 752 | | - { type: "text" as const, text: "replacement" }, | 753 | | - { type: "reasoning" as const, text: "reasoning", time: { created: 3 } }, | 754 | | - ] | 755 | | - const api = OpenCode.make({ | 756 | | - baseUrl: "http://opencode.local", | 757 | | - fetch: async () => { | 758 | | - const current = ++requests | 759 | | - if (current === 2) await release.promise | 760 | | - return Response.json({ | 761 | | - data: [ | 762 | | - { | 763 | | - id: "msg_assistant", | 764 | | - type: "assistant", | 765 | | - agent: "build", | 766 | | - model: { id: "model", providerID: "provider" }, | 767 | | - content: current === 3 ? content : [{ type: "text", text: "original" }], | 768 | | - time: { created: 1, completed: 2 }, | 769 | | - }, | 770 | | - ], | 771 | | - cursor: {}, | 772 | | - }) | 773 | | - }, | 774 | | - }) | 775 | | - const setup = createRoot((dispose) => ({ | 776 | | - data: createData({ | 777 | | - api: () => api, | 778 | | - directory: "/project", | 779 | | - event: { | 780 | | - on: () => () => {}, | 781 | | - listen(handler) { | 782 | | - listeners.add(handler) | 783 | | - return () => listeners.delete(handler) | 784 | | - }, | 785 | | - }, | 786 | | - }), | 787 | | - dispose, | 788 | | - })) | 789 | | - | 790 | | - try { | 791 | | - await setup.data.session.message.sync("ses_refresh") | 792 | | - setup.data.session.message.invalidate("ses_refresh") | 793 | | - const stale = setup.data.session.message.sync("ses_refresh") | 794 | | - await wait(() => requests === 2) | 795 | | - const updated: OpenCodeEvent = { | 796 | | - id: "evt_message_updated", | 797 | | - created: 3, | 798 | | - type: "session.message.content.updated", | 799 | | - durable: { aggregateID: "ses_refresh", seq: 3, version: 1 }, | 800 | | - data: { | 801 | | - sessionID: "ses_refresh", | 802 | | - messageID: "msg_assistant", | 803 | | - content, | 804 | | - }, | 805 | | - } | 806 | | - listeners.forEach((listener) => listener({ name: updated.type, details: updated })) | 807 | | - | 808 | | - expect(setup.data.session.message.list("ses_refresh")[0]).toMatchObject({ content }) | 809 | | - release.resolve() | 810 | | - await stale | 811 | | - await wait(() => requests === 3) | 812 | | - expect(setup.data.session.message.list("ses_refresh")[0]).toMatchObject({ content }) | 813 | | - } finally { | 814 | | - setup.dispose() | 815 | | - } | 816 | | -}) | 817 | | - | 818 | 747 | test.each([ | 819 | 748 | "session.execution.succeeded", | 820 | 749 | "session.execution.failed", | |
Collapse file Copy file name to clipboardExpand all lines: packages/core/src/session.ts -10Lines changed: 0 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -31,10 +31,7 @@ import { | 31 | 31 | ForkEmptyError, | 32 | 32 | InboxConflictError, | 33 | 33 | MessageDecodeError, | 34 | | - MessageIncompleteError, | 35 | | - MessageNotAssistantError, | 36 | 34 | MessageNotFoundError, | 37 | | - MessageToolIncompleteError, | 38 | 35 | NotFoundError, | 39 | 36 | PromptConflictError, | 40 | 37 | SkillNotFoundError, | @@ -101,10 +98,7 @@ export { | 101 | 98 | CompactionConflictError, | 102 | 99 | InboxConflictError, | 103 | 100 | MessageDecodeError, | 104 | | - MessageIncompleteError, | 105 | | - MessageNotAssistantError, | 106 | 101 | MessageNotFoundError, | 107 | | - MessageToolIncompleteError, | 108 | 102 | NotFoundError, | 109 | 103 | PromptConflictError, | 110 | 104 | SkillNotFoundError, | @@ -136,9 +130,6 @@ export interface Interface { | 136 | 130 | sessionID: SessionSchema.ID | 137 | 131 | messageID: SessionMessage.ID | 138 | 132 | }) => Effect.Effect<SessionMessage.Info | undefined> | 139 | | - readonly updateMessage: ( | 140 | | - input: Parameters<Session.Handle["updateMessage"]>[0] & { readonly sessionID: SessionSchema.ID }, | 141 | | - ) => ReturnType<Session.Handle["updateMessage"]> | 142 | 133 | readonly context: ( | 143 | 134 | sessionID: SessionSchema.ID, | 144 | 135 | ) => Effect.Effect<SessionMessage.Info[], NotFoundError | MessageDecodeError> | @@ -357,7 +348,6 @@ const layer = Layer.effect( | 357 | 348 | return yield* store.messages(input) | 358 | 349 | }), | 359 | 350 | message: (input) => sessions.forSession(input.sessionID).message(input.messageID), | 360 | | - updateMessage: (input) => sessions.forSession(input.sessionID).updateMessage(input), | 361 | 351 | context: Effect.fn("Session.context")(function* (sessionID) { | 362 | 352 | yield* result.get(sessionID) | 363 | 353 | return yield* store.context(sessionID) | |
|