startRun notes the entry on the request's context (noteEntry); serve copies it to Try.Entry and Try.EntryWhy (the claudePrint code). The Routing row shows a TUI or -p chip, with the reason in its title, in en/zh/zh-TW/ja/de. The bridge page also records the answer to Tossipe on X: a local Claude Code on a remote magpie sends its history each turn, and the remote resumes its session and types only the new turn, so the history isn't sent to Anthropic twice. Run on mote: TestEntryNoted; routing-entry.test.cjs in both engines, five languages, 1000 and 480 wide; i18n-keys (a key repeating a Go string is reworded). Not tried: a real Claude Code run on each path.
27 lines
808 B
Go
27 lines
808 B
Go
package gateway
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
// A try's context carries how its Claude Code run was made: the
|
|
// interactive mode, or -p and why, the last run's when it was started
|
|
// again, and nothing for a try that ran none.
|
|
func TestEntryNoted(t *testing.T) {
|
|
ctx, entry := withEntry(context.Background())
|
|
if e, w := entry(); e != "" || w != "" {
|
|
t.Fatalf("before any run: %q %q", e, w)
|
|
}
|
|
noteEntry(ctx, false, "third-party")
|
|
if e, w := entry(); e != "print" || w != "third-party" {
|
|
t.Fatalf("-p for a refused prompt: %q %q", e, w)
|
|
}
|
|
noteEntry(ctx, true, "")
|
|
if e, w := entry(); e != "tui" || w != "" {
|
|
t.Fatalf("started again in the interactive mode: %q %q", e, w)
|
|
}
|
|
// a context that carries no note is told nothing, and doesn't panic
|
|
noteEntry(context.Background(), true, "")
|
|
}
|