Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/internal/e2e/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ func TestSessionLog(t *testing.T) {
})

t.Run("should log ephemeral message", func(t *testing.T) {
if err := session.Log(t.Context(), "Ephemeral message", &copilot.LogOptions{Ephemeral: true}); err != nil {
if err := session.Log(t.Context(), "Ephemeral message", &copilot.LogOptions{Ephemeral: copilot.Bool(true)}); err != nil {
t.Fatalf("Log failed: %v", err)
}

Expand Down
11 changes: 6 additions & 5 deletions go/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,9 @@ type LogOptions struct {
// [rpc.Warning], and [rpc.Error].
Level rpc.Level
// Ephemeral marks the message as transient so it is not persisted
// to the session event log on disk.
Ephemeral bool
// to the session event log on disk. When nil the server decides the
// default; set to a non-nil value to explicitly control persistence.
Ephemeral *bool
}

// Log sends a log message to the session timeline.
Expand All @@ -730,16 +731,16 @@ type LogOptions struct {
// session.Log(ctx, "Rate limit approaching", &copilot.LogOptions{Level: rpc.Warning})
//
// // Ephemeral message (not persisted)
// session.Log(ctx, "Working...", &copilot.LogOptions{Ephemeral: true})
// session.Log(ctx, "Working...", &copilot.LogOptions{Ephemeral: copilot.Bool(true)})
func (s *Session) Log(ctx context.Context, message string, opts *LogOptions) error {
params := &rpc.SessionLogParams{Message: message}

if opts != nil {
if opts.Level != "" {
params.Level = &opts.Level
}
if opts.Ephemeral {
params.Ephemeral = &opts.Ephemeral
if opts.Ephemeral != nil {
params.Ephemeral = opts.Ephemeral
}
}

Expand Down
5 changes: 4 additions & 1 deletion go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ type ClientOptions struct {
}

// Bool returns a pointer to the given bool value.
// Use for setting AutoStart: AutoStart: Bool(false)
// Use for option fields such as AutoStart, AutoRestart, or LogOptions.Ephemeral:
//
// AutoStart: Bool(false)
// Ephemeral: Bool(true)
func Bool(v bool) *bool {
return &v
}
Expand Down
Loading