Skip to content

Commit b1578a7

Browse files
joshspicerCopilot
andcommitted
Initialize managed settings before Go events
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 4157ef1 commit b1578a7

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

go/client.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,12 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
906906
// message is dispatched) so notifications for the new session id are
907907
// routed to a registered session.
908908
initializeSession := func(sessionID string) (*Session, error) {
909-
s := newSession(sessionID, c.client, "")
910-
s.managedSettings = config.EnableManagedSettings != nil && *config.EnableManagedSettings
909+
s := newSession(
910+
sessionID,
911+
c.client,
912+
"",
913+
config.EnableManagedSettings != nil && *config.EnableManagedSettings,
914+
)
911915

912916
s.registerTools(config.Tools)
913917
s.registerPermissionHandler(config.OnPermissionRequest)
@@ -1228,8 +1232,12 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
12281232

12291233
// Create and register the session before issuing the RPC so that
12301234
// events emitted by the CLI (e.g. session.start) are not dropped.
1231-
session := newSession(sessionID, c.client, "")
1232-
session.managedSettings = config.EnableManagedSettings != nil && *config.EnableManagedSettings
1235+
session := newSession(
1236+
sessionID,
1237+
c.client,
1238+
"",
1239+
config.EnableManagedSettings != nil && *config.EnableManagedSettings,
1240+
)
12331241

12341242
session.registerTools(config.Tools)
12351243
session.registerPermissionHandler(config.OnPermissionRequest)

go/session.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,16 @@ func canvasResultError(err error) error {
366366
}
367367

368368
// newSession creates a new session wrapper with the given session ID and client.
369-
func newSession(sessionID string, client *jsonrpc2.Client, workspacePath string) *Session {
369+
func newSession(
370+
sessionID string,
371+
client *jsonrpc2.Client,
372+
workspacePath string,
373+
managedSettings bool,
374+
) *Session {
370375
s := &Session{
371376
SessionID: sessionID,
372377
workspacePath: workspacePath,
378+
managedSettings: managedSettings,
373379
client: client,
374380
clientSessionAPIs: &rpc.ClientSessionAPIHandlers{},
375381
handlers: make([]sessionHandler, 0),

0 commit comments

Comments
 (0)