The open source coding agent.
TypeScript
feat(tui): unshare command
adamdottv8825cd38113c
diff --git a/packages/opencode/src/share/share.ts b/packages/opencode/src/share/share.tsindex f498e0f4570..f58468cea8f 100644--- a/packages/opencode/src/share/share.ts+++ b/packages/opencode/src/share/share.ts@@ -67,9 +67,12 @@ export namespace Share {}export async function remove(id: string) {+ const share = await Session.getShare(id).catch(() => {})+ if (!share) return+ const { secret } = sharereturn fetch(`${URL}/share_delete`, {method: "POST",- body: JSON.stringify({ id }),+ body: JSON.stringify({ id, secret }),}).then((x) => x.json())}}diff --git a/packages/tui/internal/commands/command.go b/packages/tui/internal/commands/command.goindex 13fb3d5eb74..9c4da12ec3d 100644--- a/packages/tui/internal/commands/command.go+++ b/packages/tui/internal/commands/command.go@@ -75,6 +75,7 @@ const (SessionNewCommand CommandName = "session_new"SessionListCommand CommandName = "session_list"SessionShareCommand CommandName = "session_share"+ SessionUnshareCommand CommandName = "session_unshare"SessionInterruptCommand CommandName = "session_interrupt"SessionCompactCommand CommandName = "session_compact"ToolDetailsCommand CommandName = "tool_details"@@ -160,6 +161,12 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {Keybindings: parseBindings("<leader>s"),Trigger: "share",},+ {+ Name: SessionUnshareCommand,+ Description: "unshare session",+ Keybindings: parseBindings("<leader>u"),+ Trigger: "unshare",+ },{Name: SessionInterruptCommand,Description: "interrupt session",@@ -289,7 +296,7 @@ func LoadFromConfig(config *opencode.Config) CommandRegistry {{Name: MessagesRevertCommand,Description: "revert message",- Keybindings: parseBindings("<leader>u"),+ Keybindings: parseBindings("<leader>r"),},{Name: AppExitCommand,diff --git a/packages/tui/internal/components/chat/messages.go b/packages/tui/internal/components/chat/messages.goindex a0105ec42d8..05fa3080133 100644--- a/packages/tui/internal/components/chat/messages.go+++ b/packages/tui/internal/components/chat/messages.go@@ -309,9 +309,12 @@ func (m *messagesComponent) header(width int) string {base := styles.NewStyle().Foreground(t.Text()).Background(t.Background()).Rendermuted := styles.NewStyle().Foreground(t.TextMuted()).Background(t.Background()).RenderheaderLines := []string{}- headerLines = append(headerLines, util.ToMarkdown("# "+m.app.Session.Title, width-6, t.Background()))+ headerLines = append(+ headerLines,+ util.ToMarkdown("# "+m.app.Session.Title, width-6, t.Background()),+ )if m.app.Session.Share.URL != "" {- headerLines = append(headerLines, muted(m.app.Session.Share.URL))+ headerLines = append(headerLines, muted(m.app.Session.Share.URL+" /unshare"))} else {headerLines = append(headerLines, base("/share")+muted(" to create a shareable link"))}diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.goindex 1c326678200..cc437f80468 100644--- a/packages/tui/internal/tui/tui.go+++ b/packages/tui/internal/tui/tui.go@@ -827,6 +827,17 @@ func (a appModel) executeCommand(command commands.Command) (tea.Model, tea.Cmd)shareUrl := response.Share.URLcmds = append(cmds, tea.SetClipboard(shareUrl))cmds = append(cmds, toast.NewSuccessToast("Share URL copied to clipboard!"))+ case commands.SessionUnshareCommand:+ if a.app.Session.ID == "" {+ return a, nil+ }+ _, err := a.app.Client.Session.Unshare(context.Background(), a.app.Session.ID)+ if err != nil {+ slog.Error("Failed to unshare session", "error", err)+ return a, toast.NewErrorToast("Failed to unshare session")+ }+ a.app.Session.Share.URL = ""+ cmds = append(cmds, toast.NewSuccessToast("Session unshared successfully"))case commands.SessionInterruptCommand:if a.app.Session.ID == "" {return a, nil