fix: per-caller context on account lookup, stop on non-websocket receive, sanitize CLI output
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45f88378a6
commit
136e431917
8 files changed
+89
-7
No files matched your search
@@ -178,11 +178,14 @@ func (c *Client) Accounts(ctx context.Context) ([]Account, error) {
|
||||
}
|
||||
|
||||
// account resolves the account to use and caches it after the first success.
|
||||
// The lock is not held during the lookup, so each caller's ctx applies; a
|
||||
// concurrent duplicate lookup is harmless.
|
||||
func (c *Client) account(ctx context.Context) (Account, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.acct != nil {
|
||||
return *c.acct, nil
|
||||
cached := c.acct
|
||||
c.mu.Unlock()
|
||||
if cached != nil {
|
||||
return *cached, nil
|
||||
}
|
||||
accts, err := c.Accounts(ctx)
|
||||
if err != nil {
|
||||
@@ -207,7 +210,9 @@ func (c *Client) account(ctx context.Context) (Account, error) {
|
||||
default:
|
||||
found = &accts[0]
|
||||
}
|
||||
c.mu.Lock()
|
||||
c.acct = found
|
||||
c.mu.Unlock()
|
||||
return *found, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user