Просмотр исходного кода

feat(tui): copy share url to clipboard

adamdottv 8 месяцев назад
Родитель
Сommit
4b132656df
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      packages/tui/internal/tui/tui.go

+ 5 - 1
packages/tui/internal/tui/tui.go

@@ -398,12 +398,16 @@ func (a appModel) executeCommand(command commands.Command) (tea.Model, tea.Cmd)
 		if a.app.Session.Id == "" {
 			return a, nil
 		}
-		a.app.Client.PostSessionShareWithResponse(
+		response, _ := a.app.Client.PostSessionShareWithResponse(
 			context.Background(),
 			client.PostSessionShareJSONRequestBody{
 				SessionID: a.app.Session.Id,
 			},
 		)
+		if response.JSON200 != nil && response.JSON200.Share != nil {
+			shareUrl := response.JSON200.Share.Url
+			cmds = append(cmds, tea.SetClipboard(shareUrl))
+		}
 	case commands.SessionInterruptCommand:
 		if a.app.Session.Id == "" {
 			return a, nil