Skip to content

Commit 9c9cbb3

Browse files
committed
wip: undo properly remove messages from UI
1 parent c24fbb4 commit 9c9cbb3

25 files changed

Lines changed: 684 additions & 457 deletions

File tree

packages/opencode/src/cli/cmd/tui.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const TuiCommand = cmd({
113113
})
114114

115115
;(async () => {
116-
if (Installation.VERSION === "dev") return
116+
if (Installation.isDev()) return
117117
if (Installation.isSnapshot()) return
118118
const config = await Config.global()
119119
if (config.autoupdate === false) return

packages/opencode/src/server/server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export namespace Server {
4343

4444
export type Routes = ReturnType<typeof app>
4545

46+
export const Event = {
47+
Connected: Bus.event("server.connected", z.object({})),
48+
}
49+
4650
function app() {
4751
const app = new Hono()
4852

@@ -109,7 +113,10 @@ export namespace Server {
109113
log.info("event connected")
110114
return streamSSE(c, async (stream) => {
111115
stream.writeSSE({
112-
data: JSON.stringify({}),
116+
data: JSON.stringify({
117+
type: "server.connected",
118+
properties: {},
119+
}),
113120
})
114121
const unsub = Bus.subscribeAll(async (event) => {
115122
await stream.writeSSE({

packages/opencode/src/session/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,6 @@ export namespace Session {
540540
for (const part of userParts) {
541541
await updatePart(part)
542542
}
543-
// mark session as updated since a message has been added to it
544-
await update(input.sessionID, (_draft) => {})
545543

546544
if (isLocked(input.sessionID)) {
547545
return new Promise((resolve) => {
@@ -566,6 +564,7 @@ export namespace Session {
566564
const [preserve, remove] = splitWhen(msgs, (x) => x.info.id === messageID)
567565
msgs = preserve
568566
for (const msg of remove) {
567+
if (msg.info.id === userMsg.id) continue
569568
await Storage.remove(`session/message/${input.sessionID}/${msg.info.id}`)
570569
await Bus.publish(MessageV2.Event.Removed, { sessionID: input.sessionID, messageID: msg.info.id })
571570
}
@@ -577,11 +576,15 @@ export namespace Session {
577576
for (const part of removeParts) {
578577
await Storage.remove(`session/part/${input.sessionID}/${last.info.id}/${part.id}`)
579578
await Bus.publish(MessageV2.Event.PartRemoved, {
579+
sessionID: input.sessionID,
580580
messageID: last.info.id,
581581
partID: part.id,
582582
})
583583
}
584584
}
585+
await update(input.sessionID, (draft) => {
586+
draft.revert = undefined
587+
})
585588
}
586589

587590
const previous = msgs.filter((x) => x.info.role === "assistant").at(-1)?.info as MessageV2.Assistant

packages/opencode/src/session/message-v2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export namespace MessageV2 {
284284
PartRemoved: Bus.event(
285285
"message.part.removed",
286286
z.object({
287+
sessionID: z.string(),
287288
messageID: z.string(),
288289
partID: z.string(),
289290
}),

packages/opencode/src/tool/read.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const ReadTool = Tool.define("read", {
1414
description: DESCRIPTION,
1515
parameters: z.object({
1616
filePath: z.string().describe("The path to the file to read"),
17-
offset: z.number().describe("The line number to start reading from (0-based)").optional(),
18-
limit: z.number().describe("The number of lines to read (defaults to 2000)").optional(),
17+
offset: z.coerce.number().describe("The line number to start reading from (0-based)").optional(),
18+
limit: z.coerce.number().describe("The number of lines to read (defaults to 2000)").optional(),
1919
}),
2020
async execute(params, ctx) {
2121
let filePath = params.filePath

packages/sdk/.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 26
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-5748199af356c3243a46a466e73b5d0bab7eaa0c56895e1d0f903d637f61d0bb.yml
3-
openapi_spec_hash: c04f6b6be54b05d9b1283c24e870163b
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-62d8fccba4eb8dc3a80434e0849eab3352e49fb96a718bb7b6d17ed8e582b716.yml
3+
openapi_spec_hash: 4ff9376cf9634e91731e63fe482ea532
44
config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3

packages/sdk/api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Methods:
4141

4242
Types:
4343

44-
- <code><a href="./src/resources/find.ts">Match</a></code>
4544
- <code><a href="./src/resources/find.ts">Symbol</a></code>
4645
- <code><a href="./src/resources/find.ts">FindFilesResponse</a></code>
4746
- <code><a href="./src/resources/find.ts">FindSymbolsResponse</a></code>

packages/sdk/src/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import {
4646
FindSymbolsResponse,
4747
FindTextParams,
4848
FindTextResponse,
49-
Match,
5049
Symbol,
5150
} from './resources/find';
5251
import {
@@ -789,7 +788,6 @@ export declare namespace Opencode {
789788

790789
export {
791790
Find as Find,
792-
type Match as Match,
793791
type Symbol as Symbol,
794792
type FindFilesResponse as FindFilesResponse,
795793
type FindSymbolsResponse as FindSymbolsResponse,

packages/sdk/src/resources/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export interface Mode {
7777
model?: Mode.Model;
7878

7979
prompt?: string;
80+
81+
temperature?: number;
8082
}
8183

8284
export namespace Mode {

packages/sdk/src/resources/config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export interface Config {
2020
*/
2121
$schema?: string;
2222

23+
/**
24+
* Modes configuration, see https://opencode.ai/docs/modes
25+
*/
26+
agent?: Config.Agent;
27+
2328
/**
2429
* @deprecated Use 'share' field instead. Share newly created sessions
2530
* automatically
@@ -97,6 +102,33 @@ export interface Config {
97102
}
98103

99104
export namespace Config {
105+
/**
106+
* Modes configuration, see https://opencode.ai/docs/modes
107+
*/
108+
export interface Agent {
109+
general?: Agent.General;
110+
111+
[k: string]: Agent.AgentConfig | undefined;
112+
}
113+
114+
export namespace Agent {
115+
export interface General extends ConfigAPI.ModeConfig {
116+
description: string;
117+
}
118+
119+
export interface AgentConfig extends ConfigAPI.ModeConfig {
120+
description: string;
121+
}
122+
}
123+
124+
export interface AgentConfig extends ConfigAPI.ModeConfig {
125+
description: string;
126+
}
127+
128+
export interface AgentConfig extends ConfigAPI.ModeConfig {
129+
description: string;
130+
}
131+
100132
export interface Experimental {
101133
hook?: Experimental.Hook;
102134
}
@@ -438,10 +470,14 @@ export interface McpRemoteConfig {
438470
}
439471

440472
export interface ModeConfig {
473+
disable?: boolean;
474+
441475
model?: string;
442476

443477
prompt?: string;
444478

479+
temperature?: number;
480+
445481
tools?: { [key: string]: boolean };
446482
}
447483

0 commit comments

Comments
 (0)