diff --git a/internal/agent/agents.go b/internal/agent/agents.go index bdb08fc68..0d2e9a204 100644 --- a/internal/agent/agents.go +++ b/internal/agent/agents.go @@ -189,6 +189,13 @@ var others = []*Agent{ // ("pi-desktop/0.1.0"), it is told apart from Pi by that name, which // Pi's "pi-" would take otherwise (#1966, dgmico) {ID: "pi-desktop", Name: "PI-Desktop", Icon: "pi", UA: []string{"pi-desktop"}}, + // FlowDown (wiki.qaq.flow) and Bob (com.hezongyidev.Bob) set no + // User-Agent of their own: FlowDown's sources have none, and Bob's + // requests go out through the system's networking, which names the + // app's executable first ("FlowDown/ CFNetwork/… Darwin/…"). + // Icons are the apps' own App Store icons (#shannnnnks on X). + {ID: "flowdown", Name: "FlowDown", Icon: "flowdown-color", UA: []string{"flowdown"}}, + {ID: "bob", Name: "Bob", Icon: "bob-color", UA: []string{"bob/"}}, // Kimi Code Desktop runs Kimi Code's engine on ~/.kimi-code, so it // reaches magpie through Kimi Code's config, under a client name of // its own ("kimi-code-desktop/…", jiabubu on Discord). Its icon is the diff --git a/internal/agent/flowdown_bob_test.go b/internal/agent/flowdown_bob_test.go new file mode 100644 index 000000000..3dee94d58 --- /dev/null +++ b/internal/agent/flowdown_bob_test.go @@ -0,0 +1,33 @@ +package agent + +import ( + "os" + "path/filepath" + "slices" + "testing" + + "github.com/yetone/magpie/internal/usage" +) + +// shannnnnks on X asked for FlowDown's and Bob's icons: their requests +// carry the system networking's User-Agent, naming the app first, and are +// drawn with the app's own icon. +func TestFlowDownAndBobAreClients(t *testing.T) { + for ua, want := range map[string]string{ + "FlowDown/1234 CFNetwork/1568.100.1 Darwin/24.0.0": "flowdown", + "Bob/2.0.1 CFNetwork/1568.100.1 Darwin/24.0.0": "bob", + "Bobby/1.0": "Bobby", + } { + if got := usage.AgentOf(ua); got != want { + t.Errorf("%q: %q, want %q", ua, got, want) + } + } + for _, id := range []string{"flowdown", "bob"} { + if !slices.ContainsFunc(Clients(), func(a *Agent) bool { return a.ID == id && a.Icon == id+"-color" }) { + t.Errorf("%s isn't a client the Usage views draw", id) + } + if _, err := os.Stat(filepath.Join("..", "gui", "assets", "icons", id+"-color.svg")); err != nil { + t.Errorf("%s has no icon file: %v", id, err) + } + } +} diff --git a/internal/gui/assets/icons/bob-color.svg b/internal/gui/assets/icons/bob-color.svg new file mode 100644 index 000000000..b1a0e1696 --- /dev/null +++ b/internal/gui/assets/icons/bob-color.svg @@ -0,0 +1 @@ + diff --git a/internal/gui/assets/icons/flowdown-color.svg b/internal/gui/assets/icons/flowdown-color.svg new file mode 100644 index 000000000..9ffb2fab8 --- /dev/null +++ b/internal/gui/assets/icons/flowdown-color.svg @@ -0,0 +1 @@ +