From a1fc44bb0d851f240a345cf3a1c76d5a9f78a3d2 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 16 Mar 2026 15:12:39 -0400 Subject: [PATCH] chore(events): add events for the CLI session series of commands (#2408) --- internal/cmd/session.go | 16 ++++++++++++++++ internal/event/all.go | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/internal/cmd/session.go b/internal/cmd/session.go index 67f40a0cea7442efe5d36600dc27260ab66b2320..f4267f7d57300ac91504adbc0da01ff149b71412 100644 --- a/internal/cmd/session.go +++ b/internal/cmd/session.go @@ -17,6 +17,7 @@ import ( "github.com/charmbracelet/colorprofile" "github.com/charmbracelet/crush/internal/config" "github.com/charmbracelet/crush/internal/db" + "github.com/charmbracelet/crush/internal/event" "github.com/charmbracelet/crush/internal/message" "github.com/charmbracelet/crush/internal/session" "github.com/charmbracelet/crush/internal/ui/chat" @@ -126,6 +127,9 @@ func sessionSetup(cmd *cobra.Command) (context.Context, *sessionServices, func() } func runSessionList(cmd *cobra.Command, _ []string) error { + event.SetNonInteractive(true) + event.SessionListed(sessionListJSON) + ctx, svc, cleanup, err := sessionSetup(cmd) if err != nil { return err @@ -249,6 +253,9 @@ func resolveSessionID(ctx context.Context, svc session.Service, id string) (sess } func runSessionShow(cmd *cobra.Command, args []string) error { + event.SetNonInteractive(true) + event.SessionShown(sessionShowJSON) + ctx, svc, cleanup, err := sessionSetup(cmd) if err != nil { return err @@ -273,6 +280,9 @@ func runSessionShow(cmd *cobra.Command, args []string) error { } func runSessionDelete(cmd *cobra.Command, args []string) error { + event.SetNonInteractive(true) + event.SessionDeletedCommand(sessionDeleteJSON) + ctx, svc, cleanup, err := sessionSetup(cmd) if err != nil { return err @@ -305,6 +315,9 @@ func runSessionDelete(cmd *cobra.Command, args []string) error { } func runSessionRename(cmd *cobra.Command, args []string) error { + event.SetNonInteractive(true) + event.SessionRenamed(sessionRenameJSON) + ctx, svc, cleanup, err := sessionSetup(cmd) if err != nil { return err @@ -338,6 +351,9 @@ func runSessionRename(cmd *cobra.Command, args []string) error { } func runSessionLast(cmd *cobra.Command, _ []string) error { + event.SetNonInteractive(true) + event.SessionLastShown(sessionLastJSON) + ctx, svc, cleanup, err := sessionSetup(cmd) if err != nil { return err diff --git a/internal/event/all.go b/internal/event/all.go index 713421a0186fad28137ac68fabb8d594c305d2e9..ea1e4c5ccb79a6aa70e468d03dc8e5e241909433 100644 --- a/internal/event/all.go +++ b/internal/event/all.go @@ -61,3 +61,23 @@ func TokensUsed(props ...any) { func StatsViewed() { send("stats viewed") } + +func SessionListed(json bool) { + send("session listed", "json", json) +} + +func SessionShown(json bool) { + send("session shown", "json", json) +} + +func SessionLastShown(json bool) { + send("session last shown", "json", json) +} + +func SessionDeletedCommand(json bool) { + send("session deleted", "json", json) +} + +func SessionRenamed(json bool) { + send("session renamed", "json", json) +}