Branchwell

Graphley / app / design / DESIGN.md

Show the source

Graphley UI spec: Mac app (and iPhone where it applies)

For: the engineer implementing the SwiftUI. From: creative direction, Nov 24 2026. Keep: the approved Tide table palette and fonts (Sources/AnalyticsUI/Theme.swift, design/prototype.html). Everything below is built from those tokens, plus a few tones taken from graphley-site/assets/site.css or mixed from existing tokens. Every hex value is given for light and dark. Icon: see icons/RATIONALE.md. The pick is concept A, Stacked tide.

0. What's wrong today, in one paragraph

The app looks like a default SwiftUI template wearing Tide colors:

  • Fonts: they aren't bundled, so every heading and number is SF Pro (visible in the Sources & keys screenshot).
  • Stock controls: the range picker, the metric picker, the refresh button, the Google button and the Settings toggles are all stock system controls.
  • Sidebar contrast: the selected row in dark mode is white text on #5DB6D2, which fails contrast at 2.3:1.
  • Settings: they live in a separate window, use a stepper for the refresh hour, and have no place to enter keys.
  • App Store Connect: the card tells people to "Ask your agent to run set_app_store_key, or add the key in Settings." Settings has no such field, so the only way in is through an agent.
  • No way in without an agent: a new user who doesn't use one can sign in to Google and then has no way to add a site.

This spec fixes all of that with a small set of our own controls, an in-app Settings screen, and a Sources & keys screen that works without an agent.

Principles

  1. Our controls, the system's chrome. Buttons, toggles, text fields, the range selector and pills use Tide styles. The window, sidebar container, toolbar, menus, sheets and confirmation dialogs stay native.
  2. Calm and flat. One accent color. No gradients on controls, no glows, and no card shadows. The only shadows are on the selected range segment, the toggle knob and tooltips.
  3. Plain words. Say what happens: "Save Key", "Sign In with Google…". Tool names like set_app_store_key only appear inside a prompt the user copies for their agent.
  4. Numbers line up. IBM Plex Mono for figures in tables, axes and deltas; Bricolage Grotesque for big numbers and headings; Instrument Sans for everything else.
  5. Capitalization (macOS HIG): title case on buttons and menu items ("Choose File…", "Save Key"), sentence case everywhere else ("Let agents set keys").

1. Foundations

1.1 Color tokens

The first nine rows exist in Theme.swift. Add the rest as Tide.* statics using Color(light:dark:).

TokenLightDarkUse
ground#E6EDEB#0B1B21Text field fill, code blocks (light), iPhone screen background
surface#F7FAF9#11252CDetail canvas, cards, sheets
sunk#DAE4E1#0A171CKPI tiles, range-selector track, pressed fills, disabled fills
ink#0E2830#E2EEECPrimary text
muted#557070#88A2A2Secondary text, icons at rest (5.1:1 on surface, light)
line#C3D2CE#21404ACard borders, dividers, chart grid
accent#1D6E8A#5DB6D2Primary buttons, selection, focus ring, links
up#2B7A57#5CC594Positive deltas, OK state
down#B0503A#E58A72Negative deltas, errors, destructive actions
new surface2#EDF3F1#163039Hover fill on secondary buttons, icon buttons and rows (site --surface-2)
new ink2#2F4C52#B4C8C7Body copy in cards and descriptions that should be softer than ink (site --ink-2)
new line2#A9BDB8#2F5561Secondary button border, dashed drop well (site --line-2)
new control#7B9390#53747BText field border, toggle-off track (3.1:1 on surface, meets WCAG 1.4.11)
new accentStrong#175A71#84CAE0Primary hover (site --accent-strong)
new accentPressed#18596F#4E9AB2Primary pressed
new accentInk#FFFFFF#06161BText and icons on accent (5.8:1 light, 8.0:1 dark)
new accentTint#E1ECEE#19343DQuiet-button hover, drop-well hover
new accentTint2#D0E1E5#1F3F4AQuiet-button pressed
new onDown#FFFFFF#1A0B07Text on destructive buttons (5.2:1 light, 7.5:1 dark)
new downHover#934938#EA9F8BDestructive hover
new downPressed#7C4337#C47966Destructive pressed
new attention#C9853A#E3A45AWarnings (series 3)
new side#EDF3F1#0E2027Sidebar fill on macOS 14–15 only (prototype --side)

Pills (background / text; every pair passes 4.5:1 for 11.5 pt semibold):

KindLight bgLight textDark bgDark text
ok#DAE8E2#276E51#1E423F#5CC594
attention#F1EADE#755B36#373C34#E3A45A
error#EDE2DE#984A38#373739#E58A72
info#D8E6E9#1D6E8A#1F3F4A#5DB6D2
neutral#E0E7E6#4A6566#263C41#88A2A2

Keep the AccentColor asset (#1D6E8A / #5DB6D2) for system controls we don't restyle, such as menus and the text cursor.

1.2 Type

Bundle the fonts first (P0). Nothing in this spec looks right in SF Pro. Add these static font files to Sources/AnalyticsUI/Resources/Fonts/ and register them once at launch with CTFontManagerRegisterFontURLs from Bundle.module, so both apps get them:

  • BricolageGrotesque-Bold.ttf and -SemiBold.ttf
  • InstrumentSans-Regular, -Medium, -SemiBold
  • IBMPlexMono-Regular, -Medium

Use static instances, not the variable font, so .weight() resolves predictably. DeltaLabel currently asks Plex Mono for .semibold, a weight we don't ship; change it to .medium.

Style (Tide.Font.*)FontMac size / lineiPhone size (relative to)WeightUse
screenTitleBricolage Grotesque28 / 32, tracking −0.332 (.largeTitle)BoldScreen headings
kpiBricolage Grotesque30 / 34—BoldKPI tile values
heroBricolage Grotesque34 / 3644 (.largeTitle)BoldDashboard number widget, iPhone hero number
cardTitleInstrument Sans14 / 1817 (.headline)SemiBoldCard and section titles
bodyInstrument Sans14 / 2016 (.body)RegularParagraphs, descriptions
rowTitleInstrument Sans13.5 / 1816 (.body)MediumSettings rows, list rows
secondaryInstrument Sans12.5 / 1714 (.subheadline)RegularScreen subtitles, card subtitles, help text
captionInstrument Sans11.5 / 1512 (.caption)RegularKPI labels, timestamps, legends
buttonInstrument Sans1316SemiBoldButton labels (12 on small buttons)
fieldLabelInstrument Sans12 / 1614SemiBoldForm labels
sectionLabelInstrument Sans10.5, uppercase, tracking +0.812SemiBoldSidebar section headers
figureIBM Plex Mono13 (tables), 11.5 (sidebar counts)13–15RegularNumbers in rows
deltaIBM Plex Mono1213Medium"+60%", "−12%"
codeIBM Plex Mono12 / 1813RegularCommands, prompts, IDs

Replace every .font(.headline), .caption and .callout in ContentView.swift with these styles.

1.3 Spacing, radius, borders, motion

  • Spacing: 4 pt grid. Detail padding 24 (iPhone 16). Gap between cards 16; between sections 24. Card padding 16 (form cards 20). 12 pt between a card's header and its content.
  • Corner radius:
    • cards 12; KPI tiles 10
    • buttons, text fields and code blocks 8; drop well 10
    • sidebar rows 8; icon buttons 7
    • pills and the range selector fully round (999)
    • iPhone: cards 16, list rows 14, hero card 20 (as today)
  • Borders: 1 pt line on cards and dividers. No card shadows.
  • Shadows (only these):
    • selected range segment: 0 1 2 rgba(14,40,48,.14) light / rgba(0,0,0,.45) dark
    • toggle knob: 0 1 1 rgba(0,0,0,.18)
    • chart tooltip: 0 6 16 −6 rgba(14,40,48,.35)
  • Motion: 150 ms ease-out for hover and pressed colors; 180 ms spring for the range selector and toggle knob; 200 ms for disclosures. With Reduce Motion on, switch states without sliding.
  • Cursor: arrow on buttons (Mac convention); pointing hand only on inline links.

2. Components

Build these once in AnalyticsUI and use them everywhere: TideButtonStyle, TideToggleStyle, TideField, RangeSelector, StatusPill, TideCard, CopyBlock, FileDropWell, EmptyState.

2.1 Buttons

Sizes (all corner radius 8):

SizeHeightHorizontal paddingFontIcon
Regular (default)301413 SemiBold13 pt SF Symbol, 6 pt gap
Small (inside rows and code blocks)241012 SemiBold—
Large (empty states; all iPhone buttons)36 Mac / 44 iPhone1814 Mac / 16 iPhone SemiBold—

Variants and states:

VariantRestHoverPressedDisabled
Primarybg accent, text accentInkbg accentStrongbg accentPressedbg sunk, text muted
Secondarybg surface, 1 pt line2 border, text inkbg surface2, border accentbg sunk, border accenttext muted, border line
Quiet (ghost)no bg, text accentbg accentTintbg accentTint2text muted
Destructivebg down, text onDownbg downHoverbg downPressedbg sunk, text muted
Quiet destructiveno bg, text down (light text #984A38)bg error-pill bgsame, 1 pt down bordertext muted

Hex values for each token are in 1.1.

Rules for using them:

  • One primary per card or sheet at most. It's the default action and answers Return (.keyboardShortcut(.defaultAction)); Cancel answers Esc.
  • Destructive (filled) appears only as the confirming button inside a confirmation dialog. In cards, use quiet destructive ("Remove Key", "Sign Out").
  • Focus: draw our own focus ring on every control (2 pt accent ring, 2 pt gap, radius + 2) and apply .focusEffectDisabled() so the blue system halo doesn't double up. Show the ring only for keyboard focus.
  • Loading: keep the label, replace the leading icon (or add one) with a small ProgressView, disable the button, and don't let the width change. Example: "Saving…", "Waiting for your browser…".

Icon button:

  • Size: 28×28 on Mac (44×44 hit area on iPhone), radius 7.
  • Glyph: 14 pt SF Symbol, medium weight.
  • States: at rest, glyph muted with no background. Hover: background surface2, glyph ink. Pressed: background sunk. Disabled: glyph line2.
  • Always set .help(...) and an accessibility label.

Copy button:

  • Look: a small secondary button with "doc.on.doc" and the label "Copy".
  • After a click: it shows "checkmark" and "Copied" in up for 1.5 s, then reverts, and posts a VoiceOver announcement "Copied". Fix its width to the wider label so it doesn't jump.
  • Clipboard: use NSPasteboard.general on Mac and UIPasteboard.general on iPhone.
public struct TideButtonStyle: ButtonStyle {
    public enum Kind { case primary, secondary, quiet, destructive, quietDestructive }
    public enum Size { case small, regular, large }
    var kind: Kind = .secondary, size: Size = .regular
    @Environment(\.isEnabled) private var enabled
    @State private var hover = false
    public func makeBody(configuration c: Configuration) -> some View {
        c.label
            .font(.custom("Instrument Sans", size: size == .small ? 12 : 13).weight(.semibold))
            .padding(.horizontal, size == .small ? 10 : size == .large ? 18 : 14)
            .frame(height: size == .small ? 24 : size == .large ? 36 : 30)
            .foregroundStyle(fg(c.isPressed))
            .background(bg(c.isPressed), in: .rect(cornerRadius: 8))
            .overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(border(c.isPressed), lineWidth: 1))
            .contentShape(.rect(cornerRadius: 8))
            .onHover { hover = $0 }
            .animation(.easeOut(duration: 0.15), value: hover)
    }
    // fg/bg/border: return the table above for (kind, enabled, hover, pressed)
}

2.2 Range selector (replaces the stock segmented Picker)

RangeSelector(selection: $model.range, options: [7, 30, 90]) with the labels "7 days", "30 days" and "90 days". The look is the prototype's .seg.

  • Track: fill sunk, 1 pt line border, fully round, 3 pt inner padding, 2 pt gap between segments.
  • Segment: height 24, horizontal padding 11, Instrument Sans 12.5 Medium, text muted.
  • Hover (unselected): text ink.
  • Selected: fill surface, text ink, and the selected-segment shadow from 1.3. The white pill slides between segments with matchedGeometryEffect (180 ms spring).
  • Focus: the whole control takes keyboard focus with the 2 pt ring; ← and → change the range.
  • Menu commands: add a View menu with "Last 7 Days" (⌘1), "Last 30 Days" (⌘2) and "Last 90 Days" (⌘3).
  • Accessibility: .accessibilityRepresentation { Picker("Date range", selection:) { … } }.
  • Where it shows: only on Overview, App Store and a site's screen. Hide it on dashboards (each widget has its own days), Agents, Sources & keys and Settings, where it does nothing today.
  • Data bug to fix with it: "90 days" compares against days 91–180, but Refresher.refreshAll(days: 90) only fetches 90 days, so every 90-day delta reads "new" or is wrong. Fetch 180 days of GA4 dailies and App Store sales on the first fill (and fill gaps after that); keep the iPhone snapshot at 90 days.

2.3 Top bar: range and refresh (0.1.7)

The top bar holds one toolbar item, right-aligned: [RangeSelector] 12 pt [● Updated 9:02 ┊ ↻]. Both are our own 30 pt capsules built the same way (sunk fill, 1 pt line border, 3 pt inset, 24 pt inner parts), and the cluster ends 24 pt from the window edge, in line with the cards. The range pill shows only on Overview, App Store and a site's screen. The detail page keeps overlay scroll bars (OverlayScrollers) even with a mouse connected, so the content column, and the bar lined up with it, never shifts between screens that scroll and screens that don't.

System chrome: one ToolbarItem(placement: .primaryAction) holding TopBarCluster, with .sharedBackgroundVisibility(.hidden) on macOS 26 so the system glass never wraps our controls, and .toolbar(removing: .title) on macOS 15+ (the title stays for the Window menu). Traffic lights and the sidebar toggle stay native.

RefreshPill (Sources/AnalyticsUI/Components.swift): a status segment (6 pt dot, 6 pt gap, Instrument Sans 12.5 with monospaced digits, the same size as the range labels), a 1×14 line2 hairline, then a 30×30 refresh button drawing a 24 pt circle that shares its centre with the pill's rounded end. The 12 pt arrow.clockwise is centred geometrically.

StateTextDotBehaviour
Fresh"Updated 9:02" (yesterday: "Updated yesterday"; older: "Updated Nov 21")upNot interactive
Stale (more than 26 hours)"Updated 2 days ago"attentionNot interactive
Refreshing"Refreshing…"line2Arrow turns in accent (0.9 s a turn) and finishes its turn before resting; button disabled
Failed sources"2 sources need attention", text in downTextdownStatus segment opens Sources & keys; refresh stays enabled
No refresh recorded, store has numbers (0.1.8)"Data through Nov 24" (newest day in the store)mutedRefresh enabled
Never (empty store)"Not refreshed yet"mutedRefresh enabled

The label sits over hidden width templates ("Updated 12:59 PM" and the label from when the refresh started), so the pill never shrinks mid-refresh and the range pill never moves. Never swap in a ProgressView.

Headings: the screen heading's top-right corner stays empty on the Mac. The dashboard's agent prompt is a PromptLine ("Try: “…” Copy") 8 pt under the subtitle; an empty dashboard puts a Copy Prompt button in its empty state instead. A site's link moves to the end of its subtitle ("… · protomota.com ↗").

2.4 Text fields (TideField)

A TextField with .textFieldStyle(.plain), wrapped in our own chrome:

  • Field: height 30, horizontal padding 10, radius 8.
  • Colors: fill ground, 1 pt control border, text ink, placeholder muted.
  • States:
    • Hover: border muted.
    • Focused: 2 pt accent border drawn inset (no outer glow).
    • Error: 2 pt down border.
    • Disabled: fill sunk, text muted.
  • Label above: fieldLabel, ink, 6 pt gap.
  • Help below: caption, muted, 4 pt gap. While there's an error, the error message replaces the help text: caption in down with "exclamationmark.circle.fill" at 11 pt.
  • Font: Instrument Sans 13 for words. For IDs, use IBM Plex Mono 13 with autocorrect off, .textContentType(nil), and whitespace trimmed on paste and on commit.
  • When to validate: on blur, then live once a field has shown an error.

2.5 File drop well for the .p8

A FileDropWell: full width, height 76, radius 10, fill ground, 1.5 pt dashed line2 border (dash 5, gap 4). Content is centered in one row:

  • "key.horizontal" icon, 18 pt, muted
  • "Drop your .p8 key file here, or" (13, ink2)
  • a small quiet "Choose File…" button that opens .fileImporter limited to UTType(filenameExtension: "p8")

States:

  • Dragging over: solid 1.5 pt accent border, fill accentTint, text "Release to add the key".
  • Loaded:
    • Look: solid 1 pt line border, fill surface. Left: "doc.fill" in accent and the file name in Plex Mono 13 ("AuthKey_2X9R4HXF34.p8"), with "Ready to save. It goes to your Keychain." below in caption muted.
    • Right: a small quiet "Replace…" button and an "xmark" icon button (help "Remove file").
  • Error: solid 1.5 pt down border, with the error under the well.

Behavior:

  • Validation: the file must start with -----BEGIN PRIVATE KEY----- and be under 4 KB. Otherwise show: "That file isn't an App Store Connect key. Choose the AuthKey_….p8 file you downloaded from App Store Connect."
  • Auto-fill the Key ID: if the file name matches AuthKey_([A-Z0-9]{10}).p8 and Key ID is empty, fill it in and set Key ID's help text to "Filled in from the file name."
  • Handling the key: never display the contents. Read the file into memory, write it to the Keychain on Save, then drop it from memory. Don't keep a bookmark to the file.
  • Accessibility: the well is one button, "Choose .p8 key file", and also accepts drops through .onDrop(of: [.fileURL]).

2.6 Toggle (TideToggleStyle), Mac

  • Switch: 32×18, track radius 9, knob 14×14 inset 2. The knob slides with a 180 ms spring.
  • Off: track control (#7B9390 / #53747B).
  • On: track accent.
  • Knob: #FFFFFF in light; ink #E2EEEC in dark (both states), with the knob shadow from 1.3.
  • Disabled: the whole switch at 45% opacity. Focus: the 2 pt ring around the track.
  • iPhone: use the native Toggle with .tint(Tide.accent). It's the right size for touch.

Toggle row (used in Settings and Agents):

  • Title in rowTitle and ink, with a description under it in secondary and muted (max width 440). The switch sits at the trailing edge, aligned with the title's first line.
  • Padding 12 vertical, 16 horizontal. Rows are separated by a 1 pt line divider inset 16, with no divider after the last row.
  • The whole row toggles on click. VoiceOver reads it as one element: title, value, description.

Checkbox (Choose Sites sheet): 16×16, radius 4, 1 pt control border. Checked: fill accent with a white (dark: accentInk) checkmark at 10 pt bold.

2.7 Status pill

  • Shape: height 20, horizontal padding 8, fully round. Text in Instrument Sans 11.5 SemiBold, after a 6 pt dot in the text color (6 pt gap).
  • Colors: the pill table in 1.1.
  • Exact words: "Connected", "Not connected", "Sign in again", "Key saved", "Not set up", "Checking…", "Key not accepted", "Needs attention", "On", "Off".
  • Accessibility: set the label as the status word only, so VoiceOver doesn't read the dot.

2.8 Card, KPI tile, code block, disclosure

Card (TideCard):

  • Look: surface fill, 1 pt line border, radius 12, padding 16 (forms 20), on the surface canvas, as in the approved prototype.
  • Header: title (cardTitle) with an optional subtitle (secondary, muted), and an optional trailing accessory (pill or small button) aligned to the title's first baseline.
  • Inside: cards never nest. Use inset rows with dividers instead.

KPI tile:

  • Look: sunk fill, radius 10, padding 12×14.
  • Content: label in caption muted (just "Visitors", no "· 30 days"), the value in kpi, then the delta in delta followed by "vs previous 30 days" in caption muted.
  • Number format: full numbers below 100,000 ("6,284"), compact above ("128K"). Today tiles use compact while tables use full numbers.

Code block (CopyBlock):

  • Look: fill ground (light) / sunk (dark), 1 pt line border, radius 8, padding 10×12, code style, text selectable.
  • Copy button: a small Copy button pinned top-right inside the block.
  • Text: commands stay on one line and scroll sideways; prompts wrap.

Disclosure: a quiet text button, "chevron.right" at 10 pt (rotates 90° when open) plus the label in 13 Medium accent. Content appears with a 200 ms height animation. Remember whether it was open for the session.

2.9 Sidebar

Keep NavigationSplitView and the native sidebar container (it becomes Liquid Glass on macOS 26; on 14–15 it's fine to fill with side). Replace the List rows with our own rows, because the system selection color is what fails contrast:

  • Section header: sectionLabel, muted, leading 10, 14 above and 6 below. "PORTFOLIO" and "SITES".
  • Row:
    • Size: height 28, horizontal padding 10, radius 8, 8 pt gap.
    • Icon: SF Symbol 15 pt, medium weight, muted.
    • Title: Instrument Sans 13 Medium, ink.
  • States:
    • Hover: fill sunk (light) / surface2 (dark).
    • Selected: fill accent, with icon, title and count in accentInk (count at 75% opacity).
  • Keyboard: ↑/↓ moves the selection (onMoveCommand); the sidebar takes focus as a whole.
  • Icons:
    • Overview: "chart.xyaxis.line" (not "waveform.path.ecg", which reads as a heart monitor)
    • App Store: "arrow.down.app"
    • each dashboard: "rectangle.3.group"
    • Agents: "terminal" (not "cpu")
    • Sources & keys: "key.horizontal"
    • Settings: "gearshape"
  • Site rows: an 8 pt color dot, the name (truncated at the end), and the visitor count in figure 11.5 muted. The count follows the selected range; today it always shows 30 days.
  • No sites yet: under SITES, show "No sites yet" (12.5, muted) and a small quiet "Add Sites…" button that opens the Choose Sites sheet (or Sources & keys if Google isn't connected).
  • Pinned to the bottom (safeAreaInset(edge: .bottom)): a Settings row, then the line "iPhone: updated 9:02" in caption muted with "iphone" at 11 pt. When sharing is off: "iPhone sharing is off".

2.10 Charts (small fixes in Charts.swift)

  • Tooltip: fill ink, text surface, radius 6, padding 6×8, numbers in Plex Mono, with the tooltip shadow. Today it's surface on a surface card, so it has no visible edge.
  • Axes: Plex Mono 10.5 muted on both axes. Grid lines in line, dashed (2, 3) except the zero line.
  • Stacked visitors chart: show the top 5 sites plus one "Other sites" band in series 7 (#8E9DA6 / #9FB0BA), as in the prototype. Eleven bands with seven colors repeat colors and look noisy.
  • Legend: replace the default legend with our own: 9 pt rounded squares (radius 2) and labels in caption muted, laid out left to right and wrapping.

3. Screens

Window: minimum 900×600, sidebar 220 wide (minimum 200). Every screen starts with a heading block: screenTitle, then the subtitle in secondary muted 4 pt below, then 20 pt before the content. Data screens use the full width. Settings and Sources & keys cap their content at 680 pt, left-aligned.

3.1 Settings (new, inside the app)

Delete the SwiftUI.Settings { SettingsView() } scene. Add .settings to SidebarItem. Move the sidebar selection into AppModel so menu commands and empty-state buttons can navigate. Add CommandGroup(replacing: .appSettings) { Button("Settings…") { model.selection = .settings }.keyboardShortcut(",") }, so ⌘, opens this screen in the main window.

Settings
How Graphley refreshes, shares with your iPhone, and works with your agents.

┌ Agents ─────────────────────────────────────────────────────────────┐
│ Let agents make changes                                        [●━] │
│ Agents can add sites and apps, build dashboards and refresh.        │
│ Every change is listed on the Agents screen.                        │
│ ─────────────────────────────────────────────────────────────────── │
│ Let agents set keys                                            [━○] │
│ Agents can save an App Store Connect key for you. Leave this off    │
│ unless you're setting one up.                                       │
│ ─────────────────────────────────────────────────────────────────── │
│ Connect an agent…                                       (quiet btn) │
└─────────────────────────────────────────────────────────────────────┘
┌ iPhone ─────────────────────────────────────────────────────────────┐
│ Share with iPhone through iCloud                               [●━] │
│ After each refresh, your Mac puts a copy of the numbers in your     │
│ private iCloud. Your iPhone reads it. Keys are never shared.        │
│ Last shared today at 9:02.                                (caption) │
└─────────────────────────────────────────────────────────────────────┘
┌ Daily refresh ──────────────────────────────────────────────────────┐
│ Refresh every day at   [ 9:00 AM ⌄ ]                                │
│ Graphley refreshes at this time while it's open. If it was closed,  │
│ it refreshes when you open it.                                      │
│ [Refresh Now]  ⌘R                                                   │
└─────────────────────────────────────────────────────────────────────┘
┌ Updates ────────────────────────────────────────────────────────────┐
│ Graphley 0.1.0 (12)                              [Check for Updates] │
│ Graphley checks for updates on its own and asks before installing.  │
└─────────────────────────────────────────────────────────────────────┘
┌ About ──────────────────────────────────────────────────────────────┐
│ Free and source available, made by Project ATOM. Graphley has no       │
│ server: your numbers stay on this Mac and in your private iCloud.   │
│ graphley.ai ↗    Help ↗    Privacy ↗                  (quiet links) │
└─────────────────────────────────────────────────────────────────────┘

Agents card:

  • "Let agents make changes": binds agentsCanWrite.
  • "Let agents set keys": binds agentsCanSetKeys. When it's turned on, show a one-line caption muted note under the row for the rest of the session: "Turn this off again after your agent saves the key."
  • "Connect an agent…": opens the Agents screen.

iPhone card:

  • "Share with iPhone through iCloud": binds shareWithIPhone.
  • Status line: "Last shared today at 9:02." / "Not shared yet. It happens after the next refresh." / when off: "Your iPhone keeps showing the last numbers it received."
  • iCloud sync failed: in down: "Couldn't share with your iPhone. Make sure this Mac is signed in to iCloud."

Daily refresh card:

  • Hour control: a secondary-styled menu button showing the hour in the user's locale ("9:00 AM" / "09:00") with "chevron.up.chevron.down" at 10 pt. It opens a native Menu of all 24 hours and binds refreshHour. This replaces the stepper.
  • "Refresh Now": secondary, with the ⌘R shortcut hint in caption muted.

Updates card:

  • Version: "Graphley {CFBundleShortVersionString} ({CFBundleVersion})".
  • "Check for Updates": secondary; disabled while !updates.canCheck.
  • When there's no updater (debug builds, no feed): replace the button with "Updates are off in this build." in caption muted.

About card: quiet link buttons with "arrow.up.right" at 10 pt, opening https://graphley.ai, https://graphley.ai/help/ and https://graphley.ai/privacy/.

3.2 Sources & keys

Heading "Sources & keys". Subtitle: "Where your numbers come from. Keys stay in your Keychain; your iPhone only gets the numbers."

Google Analytics card

Header: "Google Analytics" with a 28×28 icon tile (radius 7, fill sunk, "chart.bar.xaxis" in accent) and a pill on the right.

StatePillBodyButtons
Not connectedneutral "Not connected""Sign in with Google to read visitors, sessions and page views for your sites. Graphley only asks for read-only access."Primary "Sign In with Google…"
Waitinginfo "Checking…""Finish signing in in your browser, then come back here."Primary in its loading state, "Waiting for your browser…"; quiet "Cancel"
Connectedok "Connected""Signed in with read-only access. 12 properties found, 11 tracked." (numbers live)Secondary "Choose Sites…"; quiet destructive "Sign Out"
Sign-in endederror "Sign in again""Google ended this sign-in, so your sites stopped updating. Sign in again to pick up where you left off."Primary "Sign In Again…"
Sign-in failed(unchanged)Inline error under the button, in down: "Sign-in didn't finish. Try again, and choose Allow when Google asks."(unchanged)
  • Errors stay in their card. Show them inside the card, not as loose red text at the bottom of the screen (today's if let error { Text(error) }).
  • Sign Out asks first, with a confirmation dialog:
    • Title: "Sign out of Google?"
    • Message: "Graphley will stop updating your sites. The numbers you already have stay."
    • Buttons: destructive "Sign Out", "Cancel"
    • Then remove googleRefreshToken, and revoke the token if possible.
  • Choose Sites sheet (520 wide):
    • Header: title "Choose sites to track" (cardTitle 17), subtitle "These are the Google Analytics properties your account can read."
    • List: one row per property: checkbox, display name (rowTitle), and "Property 564127557" in code muted with the website domain after it.
    • Footer: quiet "Cancel" and primary "Track 11 Sites" (the count updates; "Save" when nothing changed).
    • Data: use the same discovery code as discover_ga4_properties. New sites get the next free colorIndex. Unchecking archives the site (no data is deleted).
    • After the first Google sign-in, open this sheet automatically.

App Store Connect card

Header: "App Store Connect" with an icon tile ("arrow.down.app") and a pill.

Not set up (pill neutral "Not set up"):

┌ App Store Connect ───────────────────────────────── (○ Not set up) ┐
│ Add an App Store Connect API key with the Sales and Reports role,  │
│ so Graphley can read daily downloads.   How to create a key ↗      │
│                                                                     │
│ Key ID                          Vendor number                       │
│ [2X9R4HXF34          ]          [85123456          ]                │
│ 10 letters and numbers.         Payments and Financial Reports,     │
│                                 top left.                           │
│ Issuer ID                                                           │
│ [57246542-96fe-1a63-e053-0824d011072a                          ]    │
│ Above the list of keys in Users and Access › Integrations.          │
│ Private key                                                         │
│ ┌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┐  │
│ ╎  ⚿  Drop your .p8 key file here, or  Choose File…              ╎  │
│ └╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┘  │
│ Apple lets you download this file only once, so keep the original   │
│ somewhere safe. Graphley keeps a copy in your Keychain.             │
│                                                       [ Save Key ]  │
│ ─────────────────────────────────────────────────────────────────── │
│ ›  Or let your agent do it                                          │
└─────────────────────────────────────────────────────────────────────┘

Form fields:

  • Layout: two columns at 560 pt or wider (Key ID and Vendor number side by side, each 220 wide); one column below that. Issuer ID and the drop well span the full width.
  • Placeholders: "2X9R4HXF34", "57246542-96fe-1a63-e053-0824d011072a", "85123456". They show the format; they aren't real values.
  • "How to create a key ↗": an inline link to Apple's documentation on creating App Store Connect API keys (developer.apple.com/documentation/appstoreconnectapi/creating-api-keys-for-app-store-connect-api).

Validation messages:

  • Key ID: "Key IDs are 10 letters and numbers, like 2X9R4HXF34." Key ID is uppercased as you type.
  • Issuer ID: "Issuer IDs look like 57246542-96fe-1a63-e053-0824d011072a."
  • Vendor number: "Vendor numbers are digits only, like 85123456."
  • Private key: the message in 2.5.

Saving:

  • "Save Key" is the primary button, disabled until all four parts are valid. On save, the button reads "Checking with Apple…" and the pill reads info "Checking…".
  • Check the key with one sales-report request for a recent day. A 404 ("no sales that day") counts as success.
  • Success: write all four Keychain items. The pill becomes ok "Key saved", and the card shows the saved state with a one-time caption line in up: "The key works. Downloads show up after the next refresh." It also offers a small secondary "Refresh Now" button.
  • Failure: nothing is saved. The pill becomes error "Key not accepted", and an error row appears above the button:
ResponseMessage
401"Apple didn't accept this key. Check the Key ID and Issuer ID, and make sure the .p8 file belongs to this key."
403"This key can't read sales reports. Create a key with the Sales and Reports role (Finance or Admin also work)."
Invalid vendor number"Apple doesn't recognize this vendor number. You'll find it in Payments and Financial Reports."
Network error"Couldn't reach Apple. Check your internet connection and try again."

Key saved (pill ok "Key saved"):

│ Key ID 2X9R4HXF34 · Issuer 57246542…072a · Vendor 85123456   (code) │
│ Updated downloads for 2 apps today at 9:02.               (caption) │
│ [Replace Key…]   Remove Key                                         │
  • "Replace Key…": reopens the form with Key ID, Issuer ID and Vendor number prefilled and the .p8 empty. Adds a quiet "Cancel" next to Save.
  • "Remove Key": asks first, with a confirmation dialog:
    • Title: "Remove the App Store Connect key?"
    • Message: "Graphley will stop updating App Store downloads. The numbers you already have stay."
    • Buttons: destructive "Remove Key", "Cancel"
  • Never show the private key, not even partly.

"Or let your agent do it" (disclosure, closed by default):

│ ⌄  Or let your agent do it                                          │
│ Paste this into Claude Code, Codex or another agent connected to    │
│ Graphley. It includes what you've typed above.                      │
│ ┌──────────────────────────────────────────────────────── [Copy] ┐  │
│ │ Save my App Store Connect API key in Graphley with its          │  │
│ │ set_app_store_key tool.                                         │  │
│ │ Key ID: 2X9R4HXF34                                              │  │
│ │ Issuer ID: 57246542-96fe-1a63-e053-0824d011072a                 │  │
│ │ Vendor number: 85123456                                         │  │
│ │ The private key is ~/Downloads/AuthKey_2X9R4HXF34.p8. The tool  │  │
│ │ reads it from the GRAPHLEY_ASC_PRIVATE_KEY environment variable │  │
│ │ of Graphley's MCP server, so restart that server with the       │  │
│ │ variable set to the file's contents. Don't show the key's       │  │
│ │ contents in our chat.                                           │  │
│ └─────────────────────────────────────────────────────────────────┘  │
│ Let agents set keys                                            [━○] │
│ Off. Your agent can't save keys until you turn this on.             │

Prompt contents:

  • Values: the prompt fills in the values from the form as they're typed. Empty fields become "<your key ID>", "<your issuer ID>" and "<your vendor number>".
  • Key file path: the file's path if one was chosen; otherwise "the AuthKey_….p8 file in my Downloads folder".
  • Behavior today: the wording matches what set_app_store_key does now. It reads GRAPHLEY_ASC_PRIVATE_KEY and refuses to replace an existing key unless it gets replace_existing: true. When a key is already saved, add the line "Replace the key that's already saved."

"Let agents set keys" in the disclosure: the same switch as in Settings (same binding).

  • Off: description "Off. Your agent can't save keys until you turn this on." in attention (light #755B36).
  • On: "On. Turn it off again after your agent saves the key."

Engineering recommendation: the environment-variable step is the clumsy part for agents. Add an optional p8_path argument to set_app_store_key. The MCP server would read and validate the file itself, so the key still never passes through chat or tool arguments. The prompt then shrinks to: "…with key ID 2X9R4HXF34, issuer ID …, vendor number 85123456 and p8_path ~/Downloads/AuthKey_2X9R4HXF34.p8."

App Store ratings row

A small row under the App Store card (not a card of its own): "App Store ratings · Public, no key needed" with an ok pill reading "On".

Last refresh card (only when something failed)

  • Header: "Last refresh needs attention" with an attention pill reading "Needs attention".
  • One row per failure: the source name in rowTitle ("Jotley · Google Analytics"), a plain-language message in secondary (see section 5), and a trailing small button that fixes it.
  • Raw error: a quiet "Details" disclosure under the rows shows the raw error in a CopyBlock, for support. The raw text never appears in the main copy.
  • Footer (caption muted): "Graphley refreshes every day at 9:00. Change the time in Settings." "Settings" is an inline link.

3.3 Agents

Heading "Agents". Subtitle: "Claude Code, Codex or any MCP client can set up Graphley and read your numbers. It all runs on this Mac."

Layout: a two-column grid, left 1.4fr and right 1fr. On windows narrower than 1000, stack the columns.

  • Recent agent activity (left):
    • Subtitle: "Every change an agent makes is listed here."
    • Row: a 72-wide time column (figure 11.5 muted: "9:02", "Yesterday", "Nov 12") and the text in body ink: "Claude Code added Textley, OpenTalon and Voxley." Show the tool name as a code chip (code 11.5, sunk fill, radius 4, padding 1×5) at the end of the line, in muted.
    • Dividers: between rows only. Show 20 rows, then a quiet "Show All" button.
    • Empty: "No agent changes yet. When an agent adds a site or builds a dashboard, it shows up here."
  • Connect an agent (right):
    • "Claude Code": label (fieldLabel), then a CopyBlock with claude mcp add graphley -- "{executablePath}" --mcp.
    • "Other MCP clients": label, then a CopyBlock with the JSON {"mcpServers": {"graphley": {"command": "{executablePath}", "args": ["--mcp"]}}}.
    • Help (caption muted): "Paste the command in Terminal. Your agent starts Graphley's MCP server whenever it needs it."
  • What agents can do (right, under Connect): the two toggle rows from Settings ("Let agents make changes", "Let agents set keys"), bound to the same settings.
  • Try asking (right): three prompt chips, each a small secondary button that copies its text when clicked:
    • "Set up Graphley with all my Google Analytics sites."
    • "Add my App Store apps to Graphley and refresh."
    • "Make a dashboard comparing Jotley and Textley visitors this month."

3.4 Overview

Heading "Overview". Subtitle: "11 sites and 2 apps · data through Nov 23".

  1. KPI row (4 tiles): Visitors, Sessions, Page views, App Store downloads. Hide the downloads tile when App Store Connect isn't set up; the other three then fill the row.
  2. "Daily visitors by site" card. Subtitle "Stacked. Point at a day to see each site." Stacked chart, 240 tall, top 5 plus "Other sites", with the custom legend.
  3. Two-column grid (0.1.8): the table takes the free width and the downloads card is 300 to 360 pt, 12 pt apart, both as tall as the taller card. When the content is narrower than 600 + 12 + 300 pt, the downloads card moves under the table at full width. Never squeeze it.
    • "Every site":
      • Subtitle: "Last 30 days vs the 30 before. Click a site to open it."
      • Columns: Site, Trend, Visitors, Change, Page views. Headers in caption muted, right-aligned except Site.
      • Rows: 32 tall, hover fill sunk, and a click opens the site. Today rows aren't clickable and there are no headers.
    • "App Store downloads": subtitle "First-time downloads, last 30 days", with a BarList by app, then "Downloads per day, all apps" as daily bars (a line exaggerates small counts). Beside the table the bars grow to end level with it (at least 160 pt); stacked, they are 180 pt. Hidden when there are no apps or no App Store Connect key.

3.5 Site

Heading: the site name. Subtitle: "Google Analytics 4 · property 564127557", plus an icon button "arrow.up.right.square" (help "Open protomota.com") when the site has a URL.

  • Tiles as tabs: remove the stock metric Picker. The four KPI tiles (Visitors, New visitors, Sessions, Page views) are the metric switch.
    • Selected tile: fill surface, 1.5 pt accent border, label in accent.
    • Hover: 1 pt line2 border.
    • Accessibility: .accessibilityAddTraits(.isSelected) on the selected tile; ←/→ move between tiles when the row has focus.
    • This removes one control, and the tiles stop being decoration.
  • Grid (1.6fr / 1fr): "{Metric} per day" (TrendChart, 240) and "Top pages" with the subtitle "Page views, last 30 days". topPages always fetches 30 days, so the label stays fixed instead of following the range.
  • New card, "Key events": a BarList of the GA4 key events Graphley already fetches (mac_installer_download, app_store_click, …), shown with friendly names:
    • "Mac downloads"
    • "App Store clicks"
    • "Source clicks"
    • "Newsletter clicks"
    • "Calls booked"
    • "Leads"

    Unknown events show their raw name in code style. Hide the card when the site has no events.

3.6 App Store

Heading "App Store". Subtitle: "First-time downloads per day, from App Store Connect."

The current subtitle says "first downloads and redownloads", but the chart only shows first downloads.

  • KPI row: one tile per app (name trimmed at ":"), plus a "Rating" tile with the average rating and "{n} ratings" as its footer.
  • "Downloads per day by platform": stacked bars, 240 tall, custom legend. Platform labels: "iPhone", "iPad", "Mac", "Apple Vision Pro".
  • "Every app": a table with the columns App, Downloads, Redownloads, Rating.
  • Empty states: see section 4.

3.7 Dashboards

Heading: the dashboard name. Subtitle: "Ask your agent to add or change widgets." Next to it, a prompt chip reading "Add a chart of Jotley visitors to my dashboard" that copies on click.

  • Grid: widgets in two columns, 12 apart. Each widget is a card titled with the widget title and the subtitle "Last {n} days".
  • Number widgets: show the delta under the number, as the KPI tiles do.
  • P2: on hover, an icon button "ellipsis" in the card header opens a menu with "Remove Widget". Add a dashed "Add a widget" card at the end, as in the prototype (radius 12, 1.5 pt dashed line2, text muted).

3.8 iPhone (where it applies)

  • Buttons: the same Tide button styles in the Large size (44 tall).
  • Pills and cards: the same pills; cards with radius 16 and a 1 pt line border on ground, as the prototype's iPhone already does.
  • Fonts: bundle and register them the same way (shared AnalyticsUI), and use the iPhone column from 1.2 with relativeTo: so Dynamic Type works.
  • Pull to refresh: .refreshable sits on the TabView, where it does nothing. Put it on each tab's ScrollView.
  • Caption: "Updated on your Mac 2 hours ago" in place of "Synced from your Mac …".
  • Stale banner: when the snapshot is more than 36 hours old, show it at the top of Today (radius 12, attention-pill colors): "These numbers are from 2 days ago. Open Graphley on your Mac to refresh."
  • Errors: "Couldn't reach iCloud. Showing the last copy." moves into the same banner style, in error colors, instead of loose red caption text.
  • Tab icons: Today "chart.xyaxis.line", Sites "list.bullet", App Store "arrow.down.app".
  • No settings on iPhone. It's a viewer, so there's nothing to set. Put "Updated on your Mac …" under the large title on every tab.

4. Empty states (exact strings)

Build one EmptyState view: 20 pt padding, left-aligned inside the card or screen where the content would be, no illustration.

  • Title: cardTitle, ink.
  • Body: secondary, ink2, max width 460.
  • Buttons: up to two, 12 pt below the body.
WhereTitleBodyButtons
Overview, first run (no sites, no apps)"Let's add your first site""Sign in with Google to bring in your Google Analytics sites. Or let your agent set everything up for you."Primary (Large) "Sign In with Google…" → Sources & keys, starting sign-in; secondary "Set Up with an Agent" → Agents
Overview, sites added but no data yet"Getting your numbers""The first refresh takes about a minute. Charts fill in as each site arrives."none; show a ProgressView
Sidebar, no sites—"No sites yet"quiet small "Add Sites…"
App Store, no key"Connect App Store Connect""Add an API key to see daily downloads for your apps. It takes about two minutes in App Store Connect."Primary "Add App Store Key" → Sources & keys, focus on Key ID
App Store, key but no apps"No apps yet""Ask your agent to “add my App Store apps to Graphley”, and they'll show up here after the next refresh."Copy chip with the quoted prompt
Site, no visitors in range(inside the chart card)"No visitors in the last 7 days."none; the chart still draws a flat baseline
Top pages, none—"No page views recorded yet."none
Dashboard with no widgets"This dashboard is empty""Ask your agent to add widgets, for example “add a chart of Jotley visitors to my dashboard”."Copy chip
Agents log—"No agent changes yet. When an agent adds a site or builds a dashboard, it shows up here."none
iPhone, no snapshot"Waiting for your Mac""Open Graphley on your Mac and turn on Share with iPhone through iCloud in Settings. Your numbers appear here after the next refresh."none
iPhone App Store, no apps"No App Store numbers yet""Add your App Store Connect key in Graphley on your Mac. Downloads appear here after the next refresh."none

5. Error messages

Map errors to plain language in one place, for example RefreshProblem(source:error:) → (message, action). Show the raw localizedDescription only inside the "Details" disclosure. Today AnalyticsError.http puts the first 200 characters of the API's response body on screen.

CauseMessageAction button
Google sign-in missing or expired (notSignedIn("Google"), invalid_grant)"Google sign-in has ended.""Sign In Again…"
GA4 403 on a property"This Google account can't read property {id} anymore.""Choose Sites…"
GA4 429 or 5xx after retries"Google was busy. Graphley will try again at the next refresh.""Retry"
App Store 401"Apple didn't accept the App Store Connect key.""Check Key" (scrolls to the card and opens Replace)
App Store 403"The App Store Connect key can't read sales reports.""Check Key"
URLError offline or timeout"Couldn't reach {Google / Apple}. Check your internet connection.""Retry"
iCloud sync failed"Couldn't share with your iPhone. Make sure this Mac is signed in to iCloud."none
Anything else"Something went wrong reading {source}. Graphley will try again at the next refresh.""Retry"

Also fix the source string in AnalyticsError.notSignedIn. It says "Sign in to {s} in Settings → Sources & keys." Sources & keys isn't in Settings. Use "Sign in to {s} in Sources & keys."


6. Problems across the app, in priority order

P0: do these first. They're what make the app feel unfinished or block people.

  1. The fonts never load. Everything renders in SF Pro (see the screenshot). Fix: bundle and register them (1.2).
  2. There's no way to enter the App Store Connect key in the app. The card sends people to Settings, which has no key field, and the copy names an MCP tool. Fix: the form, drop well and agent disclosure in 3.2.
  3. Settings is a separate, stock window with a stepper for the hour. Fix: the in-app Settings screen in 3.1, with ⌘, routed to it.
  4. The dark-mode sidebar selection is unreadable: white on #5DB6D2 is 2.3:1. Fix: custom sidebar rows with accentInk text (8.0:1), per 2.9.
  5. Without an agent, nobody can add a site. Sites only arrive through add_site, so a fresh install that signs in to Google still shows an empty SITES list. Fix: the Choose Sites sheet, opened after the first sign-in (3.2).
  6. Stock controls everywhere: two segmented pickers, the toolbar button, the bordered buttons, Form toggles and the stepper. Fix: the component set in section 2. Nothing stock remains inside the content area.
  7. The 90-day range shows wrong deltas, because only 90 days are fetched. Fix: fetch 180 days (2.2).
  8. The app icon PNGs are a broken render. Fix: icon concept A, rendered with librsvg or Chrome (icons/RATIONALE.md).

P1: make it feel cared for.

  1. Raw API errors on screen, plus loose red text under the cards. Fix: errors stay inside their card, with the message map and fix buttons from section 5.
  2. Refresh gives no feedback, and the Mac never says how fresh the numbers are. Fix: toolbar status and refresh states (2.3), and persist lastRefreshAt.
  3. The range selector shows on screens it doesn't affect. Fix: show it on Overview, App Store and site screens only.
  4. Empty screens show zeros and blank charts on first run, without an App Store key, and on empty dashboards. Fix: the empty states in section 4.
  5. The site screen has a stock metric picker and four tiles that repeat the same numbers. Fix: the tiles become the metric switch (3.5).
  6. Overview "Every site" has no headers and the rows can't be clicked; the stacked chart shows all 11 sites with colors repeating after 7. Fix: 3.4 and 2.10.
  7. The sidebar counts ignore the selected range. Fix: use model.range.
  8. Chart tooltips have no visible edge (surface on surface). Fix: the ink tooltip (2.10).
  9. Number formatting is inconsistent: "1.2K" in tiles, "1,234" in tables. Fix: full numbers below 100,000.
  10. The Agents screen shows a raw executable path with no Copy button and no per-client instructions. Fix: 3.3.
  11. KPI labels repeat "· 30 days" in every tile, while the range is already in the toolbar. Fix: label "Visitors", footer "+60% vs previous 30 days".
  12. Some icons say the wrong thing: a heart-monitor waveform for Overview, a CPU for Agents. Fix: the icon list in 2.9.

P2: worth doing next.

  1. iPhone pull-to-refresh is attached to the TabView and does nothing; there's no stale-data notice. Fix: 3.8.
  2. Key events are fetched but never shown outside dashboards. Fix: the Key events card (3.5).
  3. Dashboards can't be edited in the app (the prototype could). Fix: the "Remove Widget" menu and the "Add a widget" card (3.7).
  4. set_app_store_key needs an environment variable, which is awkward for agents. Fix: add p8_path (3.2).
  5. App Store copy and labels are off: the subtitle claims redownloads that the chart doesn't show, and platform labels come from dropFirst(9). Fix: 3.6.

7. Don'ts

  • No glow, blur halo or colored shadow on hover or focus. Focus is a solid 2 pt ring.
  • No gradients on buttons, cards or backgrounds; no purple; no extra accent colors beyond Tide.
  • No row of stat tiles unless the numbers are the point of the screen: Overview, a site, App Store. Settings, Sources & keys and Agents get none.
  • No sparkle or "AI" icons for agents; "terminal" is enough.
  • No toasts for routine success. Change the state in place: pill, button label, caption.
  • No all-caps button labels; uppercase is only for the tiny sidebar section labels.
  • Don't paint over the native window chrome, sidebar material or menus to imitate the prototype's flat window. The prototype is a picture of the content, not of the chrome.