diff options
| author | Dax <[email protected]> | 2025-07-23 20:30:46 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-23 20:30:46 -0400 |
| commit | 96866e52ce4b28d8f380d84722f411e786781f51 (patch) | |
| tree | fbe8df4e706510b3158d1659d8aa54b0c533c849 /packages/sdk/src | |
| parent | 507c975e929d1d8bd58ae26e7bbcf9537daaf5b6 (diff) | |
| download | opencode-96866e52ce4b28d8f380d84722f411e786781f51.tar.gz opencode-96866e52ce4b28d8f380d84722f411e786781f51.zip | |
basic undo feature (#1268)
Co-authored-by: adamdotdevin <[email protected]>
Co-authored-by: Jay V <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Andrew Joslin <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Tobias Walle <[email protected]>
Diffstat (limited to 'packages/sdk/src')
| -rw-r--r-- | packages/sdk/src/client.ts | 2 | ||||
| -rw-r--r-- | packages/sdk/src/resources/config.ts | 12 | ||||
| -rw-r--r-- | packages/sdk/src/resources/index.ts | 1 | ||||
| -rw-r--r-- | packages/sdk/src/resources/session.ts | 23 |
4 files changed, 36 insertions, 2 deletions
diff --git a/packages/sdk/src/client.ts b/packages/sdk/src/client.ts index c514ca877..7045719f6 100644 --- a/packages/sdk/src/client.ts +++ b/packages/sdk/src/client.ts @@ -67,6 +67,7 @@ import { SessionListResponse, SessionMessagesResponse, SessionResource, + SessionRevertParams, SessionSummarizeParams, SessionSummarizeResponse, SnapshotPart, @@ -846,6 +847,7 @@ export declare namespace Opencode { type SessionSummarizeResponse as SessionSummarizeResponse, type SessionChatParams as SessionChatParams, type SessionInitParams as SessionInitParams, + type SessionRevertParams as SessionRevertParams, type SessionSummarizeParams as SessionSummarizeParams, }; diff --git a/packages/sdk/src/resources/config.ts b/packages/sdk/src/resources/config.ts index e1fc09de5..638af98f8 100644 --- a/packages/sdk/src/resources/config.ts +++ b/packages/sdk/src/resources/config.ts @@ -305,11 +305,21 @@ export interface KeybindsConfig { messages_previous: string; /** - * Revert message + * Redo message + */ + messages_redo: string; + + /** + * @deprecated use messages_undo. Revert message */ messages_revert: string; /** + * Undo message + */ + messages_undo: string; + + /** * List available models */ model_list: string; diff --git a/packages/sdk/src/resources/index.ts b/packages/sdk/src/resources/index.ts index 50df8ff46..db8bde9b4 100644 --- a/packages/sdk/src/resources/index.ts +++ b/packages/sdk/src/resources/index.ts @@ -71,6 +71,7 @@ export { type SessionSummarizeResponse, type SessionChatParams, type SessionInitParams, + type SessionRevertParams, type SessionSummarizeParams, } from './session'; export { diff --git a/packages/sdk/src/resources/session.ts b/packages/sdk/src/resources/session.ts index 6e160321d..bb761033a 100644 --- a/packages/sdk/src/resources/session.ts +++ b/packages/sdk/src/resources/session.ts @@ -58,6 +58,13 @@ export class SessionResource extends APIResource { } /** + * Revert a message + */ + revert(id: string, body: SessionRevertParams, options?: RequestOptions): APIPromise<Session> { + return this._client.post(path`/session/${id}/revert`, { body, ...options }); + } + + /** * Share a session */ share(id: string, options?: RequestOptions): APIPromise<Session> { @@ -76,6 +83,13 @@ export class SessionResource extends APIResource { } /** + * Restore all reverted messages + */ + unrevert(id: string, options?: RequestOptions): APIPromise<Session> { + return this._client.post(path`/session/${id}/unrevert`, options); + } + + /** * Unshare the session */ unshare(id: string, options?: RequestOptions): APIPromise<Session> { @@ -231,7 +245,7 @@ export namespace Session { export interface Revert { messageID: string; - part: number; + partID?: string; snapshot?: string; } @@ -513,6 +527,12 @@ export interface SessionInitParams { providerID: string; } +export interface SessionRevertParams { + messageID: string; + + partID?: string; +} + export interface SessionSummarizeParams { modelID: string; @@ -550,6 +570,7 @@ export declare namespace SessionResource { type SessionSummarizeResponse as SessionSummarizeResponse, type SessionChatParams as SessionChatParams, type SessionInitParams as SessionInitParams, + type SessionRevertParams as SessionRevertParams, type SessionSummarizeParams as SessionSummarizeParams, }; } |
