Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

feat(ui): name subscription rows like Pi's account list, with the plan underneath

Alan Buscaglia7998aead92e8
diff --git a/packages/ui/src/accounts.css b/packages/ui/src/accounts.css
index 4d14c75..160b153 100644
--- a/packages/ui/src/accounts.css
+++ b/packages/ui/src/accounts.css
@@ -12,6 +12,12 @@
color: var(--muted);
}
+.provider-plan {
+ margin: -4px 0 8px;
+ font-size: 12px;
+ color: var(--muted);
+}
+
.provider-section > .muted {
margin: 2px 0 4px;
font-size: 12px;
diff --git a/packages/ui/src/components/AccountsPanel.tsx b/packages/ui/src/components/AccountsPanel.tsx
index cacfa98..7d3bd99 100644
--- a/packages/ui/src/components/AccountsPanel.tsx
+++ b/packages/ui/src/components/AccountsPanel.tsx
@@ -88,10 +88,16 @@ export function AccountsPanel({ auth, send, dispatch, openUrl }: AccountsPanelPr
title="Use your subscription"
hint="Sign in with a plan you already pay for."
providers={providers.filter((p) => p.methods.includes("oauth"))}
- label={(p) => p.oauthName ?? p.name}
+ label={(p) => p.name}
+ plan={(p) => (p.oauthName && p.oauthName !== p.name ? p.oauthName : undefined)}
action={(p) => (
- <button type="button" className="primary" onClick={() => login(p, "oauth")}>
- {`Sign in with ${p.oauthName ?? p.name}`}
+ <button
+ type="button"
+ className="primary"
+ aria-label={`Sign in with ${p.oauthName ?? p.name}`}
+ onClick={() => login(p, "oauth")}
+ >
+ Sign in
</button>
)}
send={send}
@@ -119,11 +125,13 @@ interface ProviderSectionProps {
hint: string;
providers: AuthProvider[];
label: (provider: AuthProvider) => string;
+ /** A second line under the name, for example the subscription plan. */
+ plan?: (provider: AuthProvider) => string | undefined;
action: (provider: AuthProvider) => ReactNode;
send: Send;
}
-function ProviderSection({ title, hint, providers, label, action, send }: ProviderSectionProps) {
+function ProviderSection({ title, hint, providers, label, plan, action, send }: ProviderSectionProps) {
if (providers.length === 0) return null;
const id = `providers-${title.toLowerCase().replace(/\W+/g, "-")}`;
return (
@@ -137,6 +145,7 @@ function ProviderSection({ title, hint, providers, label, action, send }: Provid
<b>{label(provider)}</b>
{provider.configured ? <span className="chip ok">Connected</span> : null}
</div>
+ {plan?.(provider) ? <p className="provider-plan">{plan(provider)}</p> : null}
<div className="provider-actions">
{action(provider)}
{provider.configured && provider.source === "stored" ? (
diff --git a/packages/ui/test/accounts.test.tsx b/packages/ui/test/accounts.test.tsx
index 57d4caa..f6df239 100644
--- a/packages/ui/test/accounts.test.tsx
+++ b/packages/ui/test/accounts.test.tsx
@@ -70,7 +70,8 @@ describe("AccountsPanel", () => {
const send = vi.fn();
const dispatch = vi.fn();
render(<AccountsPanel auth={base().auth} send={send} dispatch={dispatch} openUrl={vi.fn()} />);
- expect(screen.getByText("Anthropic")).toBeInTheDocument();
+ // A provider with both methods appears once in each section.
+ expect(screen.getAllByText("Anthropic")).toHaveLength(2);
expect(screen.getByText("Connected")).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: "Sign in with Claude Pro/Max" }));
expect(send).toHaveBeenCalledWith({ type: "auth_login", providerId: "anthropic", method: "oauth" });
@@ -108,8 +109,12 @@ describe("AccountsPanel", () => {
expect(
within(subscriptions)
.getAllByRole("button")
- .map((b) => b.textContent),
+ .map((b) => b.getAttribute("aria-label")),
).toEqual(["Sign in with GitHub Copilot", "Sign in with OpenAI (ChatGPT Plus/Pro)"]);
+ // Rows read like Pi's account list: the provider name, with the plan underneath when it differs.
+ expect(within(subscriptions).getByText("OpenAI Codex")).toBeInTheDocument();
+ expect(within(subscriptions).getByText("OpenAI (ChatGPT Plus/Pro)")).toHaveClass("provider-plan");
+ expect(within(subscriptions).queryAllByText("GitHub Copilot")).toHaveLength(1);
expect(within(keys).getByText("Anthropic")).toBeInTheDocument();
expect(within(keys).getByText("OpenAI")).toBeInTheDocument();
expect(within(keys).queryByText("GitHub Copilot")).toBeNull();