on main help sign in
chore(events): add events for the CLI session series of commands (#2408)
commita1fc44bb0d851f240a345cf3a1c76d5a9f78a3d2 authorChristian Rocha <christian@rocha.is> dateMon 16 Mar 2026, 15:12 (7 months ago) parent8247f4c
2 files changed+36
internal/cmd/session.go+16 internal/event/all.go+20
internal/cmd/session.go+16
@@ -17,6 +17,7 @@ import (
1717 "github.com/charmbracelet/colorprofile"
1818 "github.com/charmbracelet/crush/internal/config"
1919 "github.com/charmbracelet/crush/internal/db"
20+ "github.com/charmbracelet/crush/internal/event"
2021 "github.com/charmbracelet/crush/internal/message"
2122 "github.com/charmbracelet/crush/internal/session"
2223 "github.com/charmbracelet/crush/internal/ui/chat"
@@ -126,6 +127,9 @@ func sessionSetup(cmd *cobra.Command) (context.Context, *sessionServices, func()
126127}
127128
128129func runSessionList(cmd *cobra.Command, _ []string) error {
130+ event.SetNonInteractive(true)
131+ event.SessionListed(sessionListJSON)
132+
129133 ctx, svc, cleanup, err := sessionSetup(cmd)
130134 if err != nil {
131135 return err
@@ -249,6 +253,9 @@ func resolveSessionID(ctx context.Context, svc session.Service, id string) (sess
249253}
250254
251255func runSessionShow(cmd *cobra.Command, args []string) error {
256+ event.SetNonInteractive(true)
257+ event.SessionShown(sessionShowJSON)
258+
252259 ctx, svc, cleanup, err := sessionSetup(cmd)
253260 if err != nil {
254261 return err
@@ -273,6 +280,9 @@ func runSessionShow(cmd *cobra.Command, args []string) error {
273280}
274281
275282func runSessionDelete(cmd *cobra.Command, args []string) error {
283+ event.SetNonInteractive(true)
284+ event.SessionDeletedCommand(sessionDeleteJSON)
285+
276286 ctx, svc, cleanup, err := sessionSetup(cmd)
277287 if err != nil {
278288 return err
@@ -305,6 +315,9 @@ func runSessionDelete(cmd *cobra.Command, args []string) error {
305315}
306316
307317func runSessionRename(cmd *cobra.Command, args []string) error {
318+ event.SetNonInteractive(true)
319+ event.SessionRenamed(sessionRenameJSON)
320+
308321 ctx, svc, cleanup, err := sessionSetup(cmd)
309322 if err != nil {
310323 return err
@@ -338,6 +351,9 @@ func runSessionRename(cmd *cobra.Command, args []string) error {
338351}
339352
340353func runSessionLast(cmd *cobra.Command, _ []string) error {
354+ event.SetNonInteractive(true)
355+ event.SessionLastShown(sessionLastJSON)
356+
341357 ctx, svc, cleanup, err := sessionSetup(cmd)
342358 if err != nil {
343359 return err
internal/event/all.go+20
@@ -61,3 +61,23 @@ func TokensUsed(props ...any) {
6161func StatsViewed() {
6262 send("stats viewed")
6363}
64+
65+func SessionListed(json bool) {
66+ send("session listed", "json", json)
67+}
68+
69+func SessionShown(json bool) {
70+ send("session shown", "json", json)
71+}
72+
73+func SessionLastShown(json bool) {
74+ send("session last shown", "json", json)
75+}
76+
77+func SessionDeletedCommand(json bool) {
78+ send("session deleted", "json", json)
79+}
80+
81+func SessionRenamed(json bool) {
82+ send("session renamed", "json", json)
83+}