# Handoff: Home dashboards (company defaults + personal dashboards)

**For:** Dan's Command Builder
**From:** J&R Marketing (Joe)
**Design to match:** https://vonsol-command-v4.jandrdigital.com (use "View as" at the top to see each role)
**Phone view:** https://vonsol-command-v4.jandrdigital.com/mobile.html
**Status:** Design approved for build only after Dan says yes. Build and test on **Staging first**. Live changes only when Dan says "push live."

---

## 1. What we're building, in one paragraph

Home shows a row of dashboard tabs. Some dashboards are **company dashboards**: Dan (or any admin) builds them and chooses who sees them, by role or by person, and which one opens first for each role. The rest are **personal dashboards** that each person builds for themselves. Anyone can make their **own copy** of a company dashboard and change it, then go back to the company version any time. Every person can pick which dashboard **opens first** for them. Everything saves to their account, so it follows them to any computer or phone.

## 2. Words we use

| Word | Meaning |
|---|---|
| Card | One box on a dashboard (for example "Job health" or "Who owes us, by age"). Cards come from a fixed list (section 8). |
| Dashboard | A named, ordered list of cards, each with a size. |
| Company dashboard | Made by an admin. Shown to roles and/or people the admin picks. Only admins can change it. |
| Personal dashboard | Made by one person. Only they see it. |
| Copy | A personal dashboard made from a company dashboard. It remembers which one it came from and which version. |
| Start dashboard | The tab that opens first when that person opens Home. Marked with a ★. |
| Required | A company dashboard people can't hide. They can still make their own copy. |

## 3. Who can do what

| Action | Everyone | Admin (Dan) |
|---|---|---|
| See company dashboards assigned to their role or to them | ✓ | ✓ |
| Create, rename, rearrange, resize, delete personal dashboards | ✓ | ✓ |
| Make their own copy of a company dashboard and change it | ✓ | ✓ |
| Go back to the company version (deletes their copy) | ✓ | ✓ |
| Pick their own start dashboard | ✓ | ✓ |
| Hide a company dashboard that isn't required | ✓ | ✓ |
| Create, change, delete company dashboards | | ✓ |
| Choose who sees a company dashboard (roles, people) | | ✓ |
| Choose which company dashboard opens first for each role | | ✓ |
| Mark a company dashboard required | | ✓ |
| Turn one of their personal dashboards into a company dashboard ("Share with the team") | | ✓ |
| See who made their own copy of each company dashboard | | ✓ |

Use the roles already defined in the app's access model (`src/company/access-model.js`). The four roles in the design (Owner, Project Manager, Finance, Estimating) are samples. Admin = whoever the app already treats as an admin.

## 4. The rules (these decide every screen)

**R1. Which tabs a person sees, in this order:**
1. Company dashboards assigned to their role or to them by name,
2. minus any they hid (a required one can't be hidden),
3. minus any they replaced with their own copy (the copy takes that tab's place),
4. plus their personal dashboards, after the company ones, in the order they made them.

**R2. Which tab opens first (first match wins):**
1. The dashboard the person picked as their start dashboard, if they can still see it.
2. Their own copy of the company dashboard that opens first for their role.
3. The company dashboard set to open first for their role.
4. The first tab.

**R3. Only one company dashboard opens first per role.** Setting a new one for a role takes it off the old one.

**R4. Non-admins can't change company dashboards.** Clicking Customize on one shows: "Dan set up this dashboard for you. Make your own copy to change it. You can go back to his version anytime." with **Make my copy** and **Not now**. Make my copy creates the copy in the same tab position, carries over the ★ if it had one, and opens it in edit mode.

**R5. Admin edits to a company dashboard are a draft until Done.** While editing, show: "You're changing the company version. When you click Done, it updates for the N people it's shown to (roles). People with their own copy get a note." **Cancel changes** throws the draft away. **Done** saves it and adds 1 to the dashboard's version number.

**R6. Copies get a note when the company version changes.** If the company dashboard's version is newer than the version the copy was made from, show on the copy: "Dan updated the company version · **Use his** · **Keep mine**." Use his deletes the copy (same as Go back). Keep mine records the new version so the note goes away.

**R7. Personal dashboards save on every change.** No Save button. Debounce writes (about 500 ms) and show a small "Saved" toast.

**R8. Cards only show what the person is allowed to see.** The "Add a card" list only offers cards the person's role can see (for example, money cards need Finance or Owner access). If someone loses access, their dashboards keep the card but it shows "You don't have access to this" instead of data. Never show a number to someone who shouldn't see it, even on a company dashboard Dan assigned to them.

**R9. Deleting a company dashboard** removes it for everyone. Anyone's copy of it stays, as a plain personal dashboard (no "company version" link).

**R10. Losing a role** removes that role's company dashboards from the person's tabs. Their personal dashboards and copies stay.

**R11. At least one tab.** If someone has nothing assigned and no personal dashboards, Home shows an empty state with **＋ New dashboard**.

**R12. Names:** 1 to 32 characters. Duplicates are allowed.

## 5. Screens and states (match the design)

### Home, the dashboard bar
- **Tabs:** ★ before the start dashboard. Tabs scroll sideways when they don't fit.
- **Buttons:** ＋ New, Customize, and ••• (menu).
- **Info line** under the tabs, one of:
  - Company, non-admin: "Company dashboard · Set up by Dan for Project Managers · updated Nov 28"
  - Company, admin: "Company dashboard · Shown to Owner, Finance · opens first for Finance · required · **Change who sees it**"
  - Copy: "Your copy of “Money” · **Go back to the company version**" (or the update note from R6)
  - Personal: "Your dashboard · Only you see this" (admin also gets **Share with the team**)
  - Always: "★ Opens first for you" or **Open this one first**.
- **••• menu:** Open this one first · Duplicate as my own · Rename (personal, or admin on company) · Go back to the company version (copies) · Hide from my tabs (company, not required, non-admin) · Change who sees it (admin, company) · Share with the team (admin, personal) · Delete dashboard (personal) · Delete company dashboard (admin, shows how many people lose it).
- **＋ New:** name it and pick "Start from: Blank or any tab you can see." Opens in edit mode; if blank, opens the card list.

### Edit mode (Customize)
- Every card shows: size buttons S / M / L / XL, ↑ and ↓, ✕ remove, and a drag handle. Card content is dimmed and not clickable.
- Drag and drop to reorder. ↑ ↓ do the same thing for keyboards and phones.
- Sizes on a 12-column grid: S = 3, M = 4, L = 6, XL = 12 columns. Under 1100 px wide: S and M = 6, L and XL = 12. Phones: everything full width.
- **＋ Add a card** opens a side panel listing allowed cards; ones already on the dashboard say "On this dashboard".
- **Done** leaves edit mode. While editing, switching tabs is blocked ("Click Done first").

### Normal mode
- Clicking a card opens a side panel with the detail behind it (the "drill-in"). Enter does the same from the keyboard.

### Admin › Dashboards (new tab in Admin)
1. A table of company dashboards: name, card count, last updated, required, **Shown to** (role chips + named people), **Opens first for**, **Copies** ("Kirsten made a copy"), and the buttons **Who sees it**, **Edit cards** (opens it on Home in edit mode), **Preview as…** (shows Home as someone it's assigned to).
2. A **Who sees what** grid: people down the side, company dashboards across the top. Each cell shows ★ Yes (opens first), ✓, Own copy, Hidden, or —.
3. **＋ New company dashboard** opens the same "Who sees it" panel, then takes Dan to Home in edit mode.

### "Who sees it" panel (admin)
Name · roles to show it to (with head counts) · individual people · "Open it first for" roles · Required switch · Save. The success message gives the count: "Money: shown to 3 people."

### Settings › My dashboards
- **Open this one first:** dropdown of their tabs.
- **Hidden dashboards:** list, with **Show them again**.
- **Start over:** deletes their personal dashboards and copies and clears their choices, back to what Dan set up.

## 6. Phones
- Same rules and data. Dashboards are one column.
- Tabs scroll sideways. ＋ New, Customize and ••• sit in one row under the tabs.
- Customize: press and hold about 0.2 seconds to drag (SortableJS `delay: 180, delayOnTouchOnly: true`), or use ↑ ↓. Size buttons are hidden, since everything is full width.
- Side panels (card list, detail, Who sees it) open full screen.

## 7. Data (Supabase, schema `vonsol_core`)

**Put every table change in a migration file in GitHub** (`supabase/migrations/`), reviewed before it runs on Staging. Today, 34 database objects the app uses have no migration in GitHub; don't add to that gap.

```sql
-- One row per dashboard, company or personal
create table vonsol_core.dashboards (
  id uuid primary key default gen_random_uuid(),
  scope text not null check (scope in ('company','personal')),
  owner_user_id uuid references auth.users(id),          -- null for company
  name text not null check (char_length(name) between 1 and 32),
  layout jsonb not null default '[]',                     -- [{ "card": "jobs", "size": "l", "settings": {} }, ...] in display order
  required boolean not null default false,                -- company only
  version int not null default 1,                         -- company: +1 on every published change
  source_dashboard_id uuid references vonsol_core.dashboards(id) on delete set null, -- copies only
  source_version int,                                     -- company version the copy was made from
  created_by uuid not null, updated_by uuid not null,
  created_at timestamptz not null default now(), updated_at timestamptz not null default now(),
  check ((scope = 'company' and owner_user_id is null) or (scope = 'personal' and owner_user_id is not null))
);

-- Who sees a company dashboard, and where it opens first
create table vonsol_core.dashboard_assignments (
  dashboard_id uuid not null references vonsol_core.dashboards(id) on delete cascade,
  target_type text not null check (target_type in ('role','user')),
  target_id text not null,                                -- role key, or user id
  is_start boolean not null default false,                -- roles only
  primary key (dashboard_id, target_type, target_id)
);
create unique index one_start_per_role on vonsol_core.dashboard_assignments (target_id)
  where target_type = 'role' and is_start;

-- Each person's choices
create table vonsol_core.dashboard_prefs (
  user_id uuid primary key references auth.users(id),
  start_dashboard_id uuid references vonsol_core.dashboards(id) on delete set null,
  hidden_dashboard_ids uuid[] not null default '{}',
  updated_at timestamptz not null default now()
);
```

Why `layout` is one JSON column: a dashboard always loads and saves as a whole, and the version number covers the whole layout. If you'd rather use a `dashboard_cards` table, that's fine as long as R5 (draft until Done) and the version number still work.

**Row-level security (required):**
- Personal dashboards: read and write only by `owner_user_id`.
- Company dashboards: read by anyone assigned (role or user); write only by admins.
- Assignments: read by admins and by the assigned person; write only by admins.
- Prefs: read and write only by that user.
- Card data is protected by the existing data rules. The dashboard tables store layout only, never numbers.

**Activity log:** write these to the existing Admin "Recent access changes" log: company dashboard created, changed (with version), deleted, assignment changed, start-for-role changed, required changed. Personal changes don't need logging.

**Seed (Staging only):** use the sample company dashboards from the design (Company overview, Money, Jobs & bids, Bid desk, My team) with fake data. Don't copy live data into Staging.

## 8. Cards (the card list)

Each card is a registry entry: key, title, department label, default size, who can see it, and how it gets its data. The data sources below are what the design assumes; confirm each one against what the app has today, and flag any that don't exist yet instead of faking them.

| Key | Title | Default size | Who can see it | Data |
|---|---|---|---|---|
| kpi-owed | Owed to us | S | Owner, Finance | Accounting / billing |
| kpi-billed | Billed this month | S | Owner, Finance | Pay apps |
| kpi-overdue | Overdue in Procore | S | Everyone | Procore open items |
| kpi-bids | Bids due · 14 days | S | Owner, Estimating, PM | Bids |
| decisions | Needs you | L | Everyone (their own) | Command decisions |
| jobs | Job health | L | Everyone (their jobs) | Projects + Procore |
| cash | Billed vs collected | L | Owner, Finance | Billing |
| aging | Who owes us, by age | M | Owner, Finance | AR aging |
| pipeline | Bid pipeline | M | Owner, Estimating | Bids / leads |
| bids | Bids coming due | M | Owner, Estimating, PM | Bids |
| team | Team load | M | Owner, PM | Tasks by person |
| waiting | Waiting on others | M | Everyone (their own) | Tasks marked waiting |
| activity | Live activity | M | Everyone | Activity feed |
| upcoming | Coming up | M | Everyone (their own) | Tasks + calendar |
| agents | AI agents at work | M | Everyone | Agent status |
| leads | Leads to chase | M | Owner, Estimating | Leads |
| handoff | Hand something off | M | Everyone | Creates a hand-off request |

Every card also has a detail view (the side panel when clicked).

## 9. How this fits what's already built

The builder already added a **Daily dashboard / Board** switch on Home (commit `74c61f5`, `state.homeLayout`). Recommended:
- The current **Daily dashboard** becomes the seed for the Owner's company dashboard.
- The **Board** (move tasks between columns) becomes a card, "Task board", that people can add like any other. Then there's one way to arrange Home, not two.
- Keep the existing Home working until the new dashboards pass on Staging.

## 10. Acceptance checks (run on Staging, with the sample people)

1. Dan sees Company overview ★, Money, Jobs & bids, Bid desk, My team, plus his personal "Monday money check".
2. A Project Manager sees Jobs & bids ★ and My team only. No money cards anywhere.
3. A PM clicks Customize on Jobs & bids, sees the "Make my copy" note, makes a copy, removes a card, clicks Done. The tab keeps its place and its ★, and the info line says "Your copy of Jobs & bids."
4. Dan changes Jobs & bids and clicks Done. The PM's copy shows "Dan updated the company version." Use his returns them to the company version; Keep mine makes the note go away.
5. Dan sets My team to open first for Finance. Money no longer opens first for Finance (one start per role), and the Finance person now opens on My team (unless they picked their own start).
6. A non-admin can't hide a required dashboard (no Hide option). They can hide a non-required one and bring it back in Settings.
7. Start over in Settings puts a person back to exactly what Dan set up.
8. Signing in on a phone shows the same tabs, order and ★ as the computer.
9. On a phone, press-and-hold drag and the ↑ ↓ arrows both reorder cards, and the order saves.
10. A person who loses Finance access sees "You don't have access to this" on any money card, never the number.
11. Every company dashboard change shows up in Admin › Activity log.
12. No change reaches Live until Dan says "push live." Record the Live build and rollback revision first.

## 11. Out of scope for this handoff

- The other pages in the design (My Work, Projects, Team, Requests, Files, Agents, Admin, Settings). They're there to show the look and are covered by separate handoffs.
- Real agent chat (it will reuse Dex chat later).
- Sharing a personal dashboard with one coworker (only admins share, and only as a company dashboard).
