Skip to content

Commit 2a67ecc

Browse files
go: change LogOptions.Ephemeral from bool to *bool (#827)
Previously, LogOptions.Ephemeral was a plain bool, so callers could not distinguish between 'not set' (zero value false) and an explicit false. This meant the SDK could never send ephemeral=false on the wire, always deferring to the server default. Change the field to *bool so nil means 'not set' (omitted from the JSON-RPC payload) and a non-nil value is forwarded as-is. This is consistent with how the other SDKs (Node, Python, .NET) handle the field.
1 parent b67e3e5 commit 2a67ecc

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

go/internal/e2e/session_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ func TestSessionLog(t *testing.T) {
981981
})
982982

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

go/session.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,9 @@ type LogOptions struct {
711711
// [rpc.Warning], and [rpc.Error].
712712
Level rpc.Level
713713
// Ephemeral marks the message as transient so it is not persisted
714-
// to the session event log on disk.
715-
Ephemeral bool
714+
// to the session event log on disk. When nil the server decides the
715+
// default; set to a non-nil value to explicitly control persistence.
716+
Ephemeral *bool
716717
}
717718

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

737738
if opts != nil {
738739
if opts.Level != "" {
739740
params.Level = &opts.Level
740741
}
741-
if opts.Ephemeral {
742-
params.Ephemeral = &opts.Ephemeral
742+
if opts.Ephemeral != nil {
743+
params.Ephemeral = opts.Ephemeral
743744
}
744745
}
745746

go/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ type ClientOptions struct {
6464
}
6565

6666
// Bool returns a pointer to the given bool value.
67-
// Use for setting AutoStart: AutoStart: Bool(false)
67+
// Use for option fields such as AutoStart, AutoRestart, or LogOptions.Ephemeral:
68+
//
69+
// AutoStart: Bool(false)
70+
// Ephemeral: Bool(true)
6871
func Bool(v bool) *bool {
6972
return &v
7073
}

0 commit comments

Comments
 (0)