Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

1.4 KB
Raw Blame
package gateway

import (
	"testing"

	"github.com/yetone/magpie/internal/provider"
)

// 0xAncientTwo on X: the Claude subscription was signed out again and again.
// A saved account switched in to Claude Code itself has its directory
// removed; the runs waiting there for their next turn hold its refresh
// token, now Claude Code's, and are let go, so none refreshes it under
// Claude Code. Runs of other accounts, and runs in Claude Code's own home
// (which read its sign-in afresh), wait on.
func TestClaudeHandOverLetsGoOfTheAccountsRuns(t *testing.T) {
	b := newSubscriptionBridge()
	run := func(owner string) *subscriptionRun {
		r := &subscriptionRun{bridge: b, pending: map[string]chan mcpToolResult{}}
		r.owner.Store(&owner)
		b.mu.Lock()
		b.idle[owner] = r
		r.idleKey = owner
		b.mu.Unlock()
		return r
	}
	moved := run("claude\x00[email protected]")
	other := run("claude\x00[email protected]")
	own := run("claude\x00[email protected]\x00" + ownHome)

	provider.ClaudeHandedOver("[email protected]")

	if !moved.closed {
		t.Fatal("a run in the handed-over account's directory waits on")
	}
	if other.closed || own.closed {
		t.Fatal("another account's run, or Claude Code's own, was let go")
	}
	b.mu.Lock()
	_, kept := b.idle["claude\x00[email protected]"]
	n := len(b.idle)
	b.mu.Unlock()
	if kept || n != 2 {
		t.Fatalf("idle runs after the hand-over: %d, moved kept %v", n, kept)
	}
}