Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: lead Tribe with the care queue and make the Needs Care tile filter it (#3791)

[._.]/ Adam Eivyff02ff9d6b9d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 04c9cf751c..90f251c2e4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -74,3 +74,4 @@
- **The "install out of sync" and "update available" notices no longer sit on top of the screen you're using.** Both were raised as permanent corner toasts, and on a phone the card landed squarely on the bottom of the viewport — covering the Ask composer and its Send button, the Add Peer form on Instances, and the process list on System Health. Since neither notice ever times out, that was the resting state of the app after any `git pull`: you had to find the small Dismiss link before the screen worked again, and the toast came back on the next poll. They are now inline banners in the app chrome, directly under the header and in normal document flow, so they push the page down instead of covering it, and dismissing the out-of-sync notice sticks for the commit you dismissed it on — a later pull raises it again.
- **The Timeline's seven backfill importers no longer outrank the day you came to look at.** Every one-time "Import … history" panel — Gmail, Spotify, Google location, Discord, WhatsApp, browser, YouTube — rendered permanently at full width between the date picker and the content, taking the whole top half of a 1440x900 viewport (and effectively the entire screen on a phone) before the activity chart or a single event appeared. They now live behind one "Import history (7)" toggle beside the date, and lay out two-per-row once expanded, so the chart and the day's events start at the top of the content area. A day with nothing recorded offers a "Backfill from an export" button in its empty state, which opens the same set — the setup path stays one click away instead of one screen tall.
- **System Health alerts now name the page that fixes them.** Every warning banner was a bare statement — "Disk usage at or above 90%" with no control, no link, and nothing to press. Each alert now carries its own remediation link chosen from the warning's type: disk goes to the disk usage breakdown, memory/CPU/process/crash-loop alerts to the process list, an app-status alert to Apps, a Postgres alert to Database settings. The three drill-in links also moved out of the bottom process card and up under the alerts, because at phone widths every control on the route sat below the fold — a glance at the page reduced to "something is wrong" with no next step on screen.
+- **Tribe now opens on the people who need a touch, and the "Needs Care" number is a control.** The page led with two blocks of pure summary — four stat tiles and a five-row ring-capacity table — before any person appeared, so at phone width the search field, the ring filter, every relationship and every **Touch** button sat below the fold: a screen announcing that 17 people are overdue with no way to act on any of them. The Care Queue is now the tab you land on, so the first screen is the queue itself with its Touch buttons. The **Needs Care** and **Coming Up** tiles became real buttons that filter the list to exactly the bucket they count (clicking the active one clears it), the filter is a shareable `?status=` deep link that the Circle roster honors too, and the ring-capacity meters collapse behind a "Ring capacity" disclosure below desktop width. The tiles themselves are a two-column grid on a phone instead of four stacked rows.
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index 7a37be8398..b7662a5425 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -163,7 +163,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `spriteRecordGroups.js` | Grouping + search for the Sprite Manager sidebar's record picker (#2932). `groupSpriteRecords(records)` → ordered `[{ key, label, records }]` under **Characters / Places / Objects** (`props` folded into Objects alongside `object`, no migration). `filterSpriteRecords(records, query, limit=8)` is the autocomplete filter — multi-term (AND) substring over `name`/`id`/`kind`, capped at `limit`. `groupKeyForKind(kind)` maps a kind to its group key (unknown → `objects`). `SPRITE_RECORD_GROUPS` / `NEW_SPRITE_KINDS` back the browse disclosure and the create-panel kind selector. Pure — no React, no I/O; the page owns the per-group icons. |
| `spriteTrimmer.js` | Pure geometry + source-list math behind the Sprite Manager's Loop Trimmer workspace (#2933). `buildTrimmerSources(walk, assets)` → the ordered animation sources the trimmer can load (every preview-strip run first, then saved trims read from the asset listing), each `{ id, kind: 'run'\|'trim', runId, direction, label, stripPath, frameCount, fps, trimmable }` — every packed-strip run is `trimmable` (layout-agnostic), while saved trims are preview-only, mirroring `spriteCollectionActions`' gate. `stripFrameGeometry(stripPreview)` → `{ frameCount, fps, cellWidth, cellHeight }` with the native 8-phase / 12fps fallback; `phaseLabelFor(index, frameCount)` names the 8 walk phases (bare `frame N` for any other length); `sanitizeTrimSlug(name)` → the server's `[a-z0-9-]+` output slug; `allColumns(n)` / `invertColumns(n, enabled)` for the frame-toggle set. `WALK_PHASES` is the shared phase-label constant (WalkWorkflow imports it here). Also holds the walk-cycle authoring knobs mirrored from `walkBounds.js` — `WALK_DEFAULT_FRAME_COUNT` / `WALK_DEFAULT_FPS`, the `WALK_FRAME_COUNT_OPTIONS` list and `walkFpsOptionsFor(fps)` (splices a current odd fps into the even-step list so the `<select>` never lies) — feeding the shared `CycleTarget` control used by both the walk workflow and the trimmer's re-derive panel (#2980). Pure — no React, no canvas, no I/O. |
| `spriteWalkUnlock.js` | The user-facing copy for a BLOCKED walk re-open (#3043/#3044), shared by the Walk Cycles header, per-direction cards, and Loop Trimmer so one server-stamped block can never be described two different ways. `walkUnlockCopy(unlock, { mode?, direction? })` → `{ text, action, prompt, acknowledgeNoClips, toast }` for a blocked scope (null when it is not blocked): a blocked-but-`acknowledgeable` scope gets the regeneration offer plus the `acknowledgeNoClips` consent flag its POST carries, a non-acknowledgeable one gets the dead-end explanation and no action. `WALK_UNLOCK_TOAST` is the ordinary unlock success message. Pure — no React, no I/O. |
-| `tribe.js` | Pure Tribe domain helpers shared by the Tribe page and its `TribeCircleMap` visualization: `RINGS` (support→core→tribe→village Dunbar rings + the uncapped `external` "outside the tribe" classification — caps, cadence defaults, Tailwind tones + `hex`), `TRIBE_RINGS` (the four inner rings the care queue/capacity/overdue counts operate over, excluding `external`), `ENERGY` (energy tiers + `hex`), `STATUS_HEX` (cadence-status → SVG stroke color), `contactStatus(contact)` (presentation wrapper over the shared `cadenceStatus` — attaches label/tone to the missing/overdue/soon/steady/`external` state) / `daysBetween(date)` (alias of the shared `daysSinceDate`), `ringFor` / `energyFor` lookups, `tagsToArray` / `tagsToInput`, and `initialsFor(name)` (node glyph). Ring `cadenceDays` mirror `DEFAULT_RING_CADENCE` in `server/services/tribe.js`; the cadence STATE MACHINE lives in `tribeCadence.js`. |
+| `tribe.js` | Pure Tribe domain helpers shared by the Tribe page and its `TribeCircleMap` visualization: `RINGS` (support→core→tribe→village Dunbar rings + the uncapped `external` "outside the tribe" classification — caps, cadence defaults, Tailwind tones + `hex`), `TRIBE_RINGS` (the four inner rings the care queue/capacity/overdue counts operate over, excluding `external`), `ENERGY` (energy tiers + `hex`), `STATUS_HEX` (cadence-status → SVG stroke color), `contactStatus(contact)` (presentation wrapper over the shared `cadenceStatus` — attaches label/tone to the missing/overdue/soon/steady/`external` state) / `daysBetween(date)` (alias of the shared `daysSinceDate`), `ringFor` / `energyFor` lookups, `tagsToArray` / `tagsToInput`, `initialsFor(name)` (node glyph), and the care-state filters shared by the summary tiles / roster / care queue (`STATUS_FILTERS`, `STATUS_FILTER_IDS`, `STATUS_FILTER_LABELS`, `matchesStatusFilter(contact, filter)` — unknown ids degrade to `all`). Ring `cadenceDays` mirror `DEFAULT_RING_CADENCE` in `server/services/tribe.js`; the cadence STATE MACHINE lives in `tribeCadence.js`. |
| `tribeCadence.js` | Mirror of `server/lib/tribeCadence.js` — the single authoritative Tribe care-cadence rules shared by the page, the Care dashboard widget, and the proactive alert: `cadenceStatus(entity)` → `{ state, daysRemaining, daysOverdue }`, `daysSinceDate(dateStr)`, `DEFAULT_CADENCE_DAYS`, `SOON_WINDOW_DAYS`. A cross-boundary contract test asserts it never drifts from the server copy. |
| `streakGlyph.js` | `streakGlyph(streak)` — the single POST streak emoji (✨ / ⚡ / 🔥 by day count) shared by the POST launcher, Morse trainer, daily widget, and dashboard streak widget. |
| `syncCounts.js` | Directional pending-sync counts for the Instances federation cards. `directionalCounts({ localMax, peerMax, ourCursor, peerCursorForUs })` → `{ toPull, toPush }` (each a non-negative Number, or `null` when unknown) from monotonic change-log seqs; `diffSeq(ahead, behind)` is the BigInt-safe clamp-at-zero subtraction (handles numeric strings past `MAX_SAFE_INTEGER`); `describeDirectional({ toPull, toPush })` renders the plain-language `{ state, text }` ("in sync" / "N to pull · M to push" / "checking…"). No React — `SyncStatusBadge` drives it. |
diff --git a/client/src/lib/tribe.js b/client/src/lib/tribe.js
index c3ceae5b6c..e17d2b298d 100644
--- a/client/src/lib/tribe.js
+++ b/client/src/lib/tribe.js
@@ -58,6 +58,31 @@ export function contactStatus(contact) {
return { label: dueLabel, tone, state, daysRemaining };
}
+// Care-state filters shared by the Tribe page's summary tiles, roster list, and
+// care queue, so "Needs Care 17" and the list it filters to can never disagree.
+// `all` is the identity filter (null state list = match everything).
+export const STATUS_FILTERS = {
+ all: null,
+ overdue: ['missing', 'overdue'],
+ soon: ['soon'],
+};
+
+export const STATUS_FILTER_IDS = Object.keys(STATUS_FILTERS);
+
+export const STATUS_FILTER_LABELS = {
+ all: 'Everyone',
+ overdue: 'Needs care',
+ soon: 'Coming up',
+};
+
+// Unknown filter ids degrade to `all` rather than hiding everyone — a stale deep
+// link should still show the roster.
+export function matchesStatusFilter(contact, filter) {
+ const states = STATUS_FILTERS[filter];
+ if (!states) return true;
+ return states.includes(contactStatus(contact).state);
+}
+
// Status → SVG stroke color for the circle-map nodes.
export const STATUS_HEX = {
missing: '#9ca3af',
diff --git a/client/src/lib/tribe.test.js b/client/src/lib/tribe.test.js
index 619d61cd9c..1dcb7acf6a 100644
--- a/client/src/lib/tribe.test.js
+++ b/client/src/lib/tribe.test.js
@@ -12,6 +12,9 @@ import {
tagsToArray,
tagsToInput,
initialsFor,
+ STATUS_FILTER_IDS,
+ STATUS_FILTER_LABELS,
+ matchesStatusFilter,
} from './tribe.js';
describe('tribe ring/energy lookups', () => {
@@ -115,3 +118,44 @@ describe('contactStatus / daysBetween', () => {
expect(STATUS_HEX.external).toMatch(/^#[0-9a-f]{6}$/i);
});
});
+
+describe('matchesStatusFilter', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date('2026-06-19T12:00:00'));
+ });
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ const overdue = { lastContact: '2026-06-01', cadenceDays: 7 };
+ const soon = { lastContact: '2026-06-15', cadenceDays: 10 };
+ const steady = { lastContact: '2026-06-18', cadenceDays: 45 };
+ const missing = { cadenceDays: 45 };
+
+ it('all matches everyone', () => {
+ expect([overdue, soon, steady, missing].every((c) => matchesStatusFilter(c, 'all'))).toBe(true);
+ });
+
+ it('overdue covers both overdue and never-contacted people', () => {
+ expect(matchesStatusFilter(overdue, 'overdue')).toBe(true);
+ expect(matchesStatusFilter(missing, 'overdue')).toBe(true);
+ expect(matchesStatusFilter(soon, 'overdue')).toBe(false);
+ expect(matchesStatusFilter(steady, 'overdue')).toBe(false);
+ });
+
+ it('soon is only the 7-day window', () => {
+ expect(matchesStatusFilter(soon, 'soon')).toBe(true);
+ expect(matchesStatusFilter(overdue, 'soon')).toBe(false);
+ expect(matchesStatusFilter(steady, 'soon')).toBe(false);
+ });
+
+ it('an unknown filter id degrades to all rather than hiding everyone', () => {
+ expect(matchesStatusFilter(steady, 'bogus')).toBe(true);
+ });
+
+ it('every filter id carries a label', () => {
+ expect(STATUS_FILTER_IDS).toEqual(['all', 'overdue', 'soon']);
+ expect(STATUS_FILTER_IDS.every((id) => Boolean(STATUS_FILTER_LABELS[id]))).toBe(true);
+ });
+});
diff --git a/client/src/pages/Tribe.jsx b/client/src/pages/Tribe.jsx
index 488f338f6d..1243bc3f2f 100644
--- a/client/src/pages/Tribe.jsx
+++ b/client/src/pages/Tribe.jsx
@@ -33,7 +33,10 @@ import { safeReadStorage, safeRemoveStorage } from '../lib/safeStorage.js';
import {
RINGS,
ENERGY,
+ STATUS_FILTER_IDS,
+ STATUS_FILTER_LABELS,
contactStatus,
+ matchesStatusFilter,
ringFor,
energyFor,
tagsToArray,
@@ -42,15 +45,19 @@ import {
const STORAGE_KEY = 'portos-tribe-v1';
+// Care Queue leads: the page's headline metric is the overdue count, so arrival
+// lands on the people who need a touch (each row carries the Touch button) rather
+// than on the full roster (#3791).
const TABS = [
+ { id: 'care', label: 'Care Queue', icon: Clock },
{ id: 'circle', label: 'Circle', icon: Network },
{ id: 'map', label: 'Map', icon: Orbit },
- { id: 'care', label: 'Care Queue', icon: Clock },
{ id: 'focus', label: 'Focus', icon: Heart },
];
const TAB_IDS = TABS.map((tab) => tab.id);
-const DEFAULT_TAB = 'circle';
+const DEFAULT_TAB = 'care';
+const DEFAULT_STATUS = 'all';
const emptyDraft = () => ({
id: null,
@@ -68,6 +75,13 @@ const emptyDraft = () => ({
notes: '',
});
+// Default values are omitted from the URL so `/tribe` stays clean.
+function withParam(params, key, value, defaultValue) {
+ if (value === defaultValue) params.delete(key);
+ else params.set(key, value);
+ return params;
+}
+
function todayISO() {
return new Date().toISOString().slice(0, 10);
}
@@ -90,19 +104,36 @@ function clearLegacyContacts() {
safeRemoveStorage(STORAGE_KEY);
}
-function StatTile({ icon: Icon, label, value, detail, className = '' }) {
- return (
- <div className={`border border-port-border bg-port-card rounded p-4 min-w-0 ${className}`}>
- <div className="flex items-start justify-between gap-3">
- <div className="min-w-0">
- <p className="text-xs uppercase tracking-wide text-gray-500">{label}</p>
- <p className="mt-1 text-2xl font-semibold text-white">{value}</p>
- {detail && <p className="mt-1 text-xs text-gray-500 truncate">{detail}</p>}
- </div>
- <Icon size={20} className="shrink-0 text-port-accent" aria-hidden="true" />
+// A tile that names the user's task (`Needs Care`) is the fastest route into it,
+// so tiles with an `onClick` render as real buttons that filter the list; the
+// rest stay inert text (#3791).
+function StatTile({ icon: Icon, label, value, detail, onClick, active = false, className = '' }) {
+ const body = (
+ <div className="flex items-start justify-between gap-2">
+ <div className="min-w-0">
+ <p className="text-xs uppercase tracking-wide text-gray-500">{label}</p>
+ <p className="mt-1 text-xl font-semibold text-white sm:text-2xl">{value}</p>
+ {detail && <p className="mt-1 text-xs text-gray-500 truncate">{detail}</p>}
</div>
+ <Icon size={20} className="shrink-0 text-port-accent" aria-hidden="true" />
</div>
);
+ const base = `rounded p-3 min-w-0 text-left sm:p-4 bg-port-card border ${className}`;
+
+ if (!onClick) {
+ return <div className={`${base} border-port-border`}>{body}</div>;
+ }
+
+ return (
+ <button
+ type="button"
+ onClick={onClick}
+ aria-pressed={active}
+ className={`${base} w-full transition-colors ${active ? 'border-port-accent/70 ring-1 ring-port-accent/30' : 'border-port-border hover:border-port-accent/50'}`}
+ >
+ {body}
+ </button>
+ );
}
function RingMeter({ ring, contacts, active, onClick }) {
@@ -727,25 +758,29 @@ function OutreachQueue() {
);
}
-function CareQueue({ contacts, onSelect, onLogTouch, onNew }) {
+function CareQueue({ contacts, statusFilter, onStatusFilterChange, onSelect, onLogTouch, onNew }) {
// External people are outside the tribe — no care cadence is owed, so they
// never appear in the queue (otherwise their null daysRemaining would sort
// them to the top alongside genuinely-overdue contacts). Memoized + status
// computed once per contact (instead of twice per comparison in the sort).
const queue = useMemo(() => contacts
- .filter((contact) => contact.ring !== 'external')
+ .filter((contact) => contact.ring !== 'external' && matchesStatusFilter(contact, statusFilter))
.map((contact) => {
const score = contactStatus(contact).daysRemaining;
return { contact, score: score == null ? -999 : score };
})
.sort((a, b) => a.score - b.score)
- .map(({ contact }) => contact), [contacts]);
+ .map(({ contact }) => contact), [contacts, statusFilter]);
- if (!queue.length) return <EmptyState onNew={onNew} />;
+ // A filtered-to-empty queue is a success state ("nobody is overdue"), not the
+ // "no relationships yet" onboarding empty — only show the latter when the whole
+ // roster is empty.
+ if (!queue.length && statusFilter === DEFAULT_STATUS) return <EmptyState onNew={onNew} />;
return (
<div className="grid gap-3">
- {queue.map((contact) => (
+ <StatusFilterBar statusFilter={statusFilter} onChange={onStatusFilterChange} />
+ {queue.length ? queue.map((contact) => (
<ContactCard
key={contact.id}
contact={contact}
@@ -753,6 +788,34 @@ function CareQueue({ contacts, onSelect, onLogTouch, onNew }) {
onSelect={() => onSelect(contact)}
onLogTouch={() => onLogTouch(contact.id)}
/>
+ )) : (
+ <div className="rounded border border-port-border bg-port-card p-8 text-center text-sm text-gray-500">
+ Nobody is in the {STATUS_FILTER_LABELS[statusFilter].toLowerCase()} bucket right now.
+ </div>
+ )}
+ </div>
+ );
+}
+
+// Care-state filter shared by the Care Queue and the Circle roster — the same
+// buckets the summary tiles route into, so a tile click and this bar stay in sync.
+function StatusFilterBar({ statusFilter, onChange }) {
+ return (
+ <div className="flex flex-wrap items-center gap-2" role="group" aria-label="Care filter">
+ {STATUS_FILTER_IDS.map((id) => (
+ <button
+ key={id}
+ type="button"
+ onClick={() => onChange(id)}
+ aria-pressed={statusFilter === id}
+ className={`rounded-full border px-3 py-1 text-xs transition-colors ${
+ statusFilter === id
+ ? 'border-port-accent/70 bg-port-accent/10 text-port-accent'
+ : 'border-port-border text-gray-400 hover:text-white'
+ }`}
+ >
+ {STATUS_FILTER_LABELS[id]}
+ </button>
))}
</div>
);
@@ -837,12 +900,26 @@ export default function Tribe() {
const prevRaw = prev.get('tab');
const prevTab = TAB_IDS.includes(prevRaw) ? prevRaw : DEFAULT_TAB;
const resolved = typeof next === 'function' ? next(prevTab) : next;
- const params = new URLSearchParams(prev);
- if (resolved === DEFAULT_TAB) params.delete('tab');
- else params.set('tab', resolved);
- return params;
+ return withParam(new URLSearchParams(prev), 'tab', resolved, DEFAULT_TAB);
}, { replace: true });
};
+ // The care-state filter lives in the URL too (`?status=overdue`), so "show me
+ // the 17 overdue people" is shareable and survives a reload.
+ const rawStatus = searchParams.get('status');
+ const statusFilter = STATUS_FILTER_IDS.includes(rawStatus) ? rawStatus : DEFAULT_STATUS;
+ const setStatusFilter = (next) => {
+ setSearchParams((prev) => withParam(new URLSearchParams(prev), 'status', next, DEFAULT_STATUS), { replace: true });
+ };
+ // Jump from a summary tile straight into the queue it describes; clicking the
+ // active tile again clears back to everyone.
+ const focusStatus = (next) => {
+ const resolved = statusFilter === next ? DEFAULT_STATUS : next;
+ setSearchParams((prev) => {
+ const params = withParam(new URLSearchParams(prev), 'status', resolved, DEFAULT_STATUS);
+ return resolved === DEFAULT_STATUS ? params : withParam(params, 'tab', 'care', DEFAULT_TAB);
+ }, { replace: true });
+ };
+ const [ringsOpen, setRingsOpen] = useState(false);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
// Bumped by every "Add / new relationship" trigger so the form can be
@@ -946,6 +1023,7 @@ export default function Tribe() {
const normalized = query.trim().toLowerCase();
return contacts.filter((contact) => {
if (ringFilter !== 'all' && contact.ring !== ringFilter) return false;
+ if (!matchesStatusFilter(contact, statusFilter)) return false;
if (!normalized) return true;
const haystack = [
contact.name,
@@ -957,7 +1035,7 @@ export default function Tribe() {
].join(' ').toLowerCase();
return haystack.includes(normalized);
});
- }, [contacts, query, ringFilter]);
+ }, [contacts, query, ringFilter, statusFilter]);
// overdue/soon already exclude external (its status state is 'external', not in
// these lists). Capacity is the Dunbar tribe horizon, so it excludes external too.
@@ -1056,6 +1134,7 @@ export default function Tribe() {
const clearFilters = () => {
setQuery('');
setRingFilter('all');
+ setStatusFilter(DEFAULT_STATUS);
};
const actions = (
@@ -1089,25 +1168,53 @@ export default function Tribe() {
)}
{!loading && (
<>
- <div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-4">
+ <div className="grid grid-cols-2 gap-3 lg:grid-cols-4">
<StatTile icon={Users} label="Relationships" value={contacts.length} detail={externalCount ? `${supportCount} support · ${externalCount} external` : `${supportCount} support ring`} />
- <StatTile icon={Clock} label="Needs Care" value={overdueCount} detail="missing or overdue" />
- <StatTile icon={Calendar} label="Coming Up" value={soonCount} detail="due within 7 days" />
+ <StatTile
+ icon={Clock}
+ label="Needs Care"
+ value={overdueCount}
+ detail="missing or overdue"
+ onClick={() => focusStatus('overdue')}
+ active={statusFilter === 'overdue'}
+ />
+ <StatTile
+ icon={Calendar}
+ label="Coming Up"
+ value={soonCount}
+ detail="due within 7 days"
+ onClick={() => focusStatus('soon')}
+ active={statusFilter === 'soon'}
+ />
<StatTile icon={Heart} label="Capacity" value={`${tribeCount}/150`} detail="village horizon" />
</div>
{activeTab === 'circle' && (
<div className="grid gap-4 xl:grid-cols-[310px_minmax(0,1fr)_minmax(330px,420px)]">
+ {/* Five ring meters are a dashboard, not the task — below xl they
+ collapse behind a disclosure so the search field and the first
+ people stay on the first screen (#3791). */}
<aside className="grid content-start gap-3">
- {RINGS.map((ring) => (
- <RingMeter
- key={ring.id}
- ring={ring}
- contacts={contacts}
- active={ringFilter === ring.id}
- onClick={() => setRingFilter(ringFilter === ring.id ? 'all' : ring.id)}
- />
- ))}
+ <button
+ type="button"
+ onClick={() => setRingsOpen((open) => !open)}
+ aria-expanded={ringsOpen}
+ className="flex items-center justify-between gap-2 rounded border border-port-border bg-port-card px-3 py-2 text-sm text-gray-300 hover:text-white xl:hidden"
+ >
+ <span>Ring capacity</span>
+ <span className="text-xs text-gray-500">{ringsOpen ? 'Hide' : 'Show'}</span>
+ </button>
+ <div className={`content-start gap-3 xl:grid ${ringsOpen ? 'grid' : 'hidden'}`}>
+ {RINGS.map((ring) => (
+ <RingMeter
+ key={ring.id}
+ ring={ring}
+ contacts={contacts}
+ active={ringFilter === ring.id}
+ onClick={() => setRingFilter(ringFilter === ring.id ? 'all' : ring.id)}
+ />
+ ))}
+ </div>
</aside>
<section className="min-w-0">
@@ -1132,7 +1239,7 @@ export default function Tribe() {
{RINGS.map((ring) => <option key={ring.id} value={ring.id}>{ring.label}</option>)}
</select>
</label>
- {(query || ringFilter !== 'all') && (
+ {(query || ringFilter !== 'all' || statusFilter !== DEFAULT_STATUS) && (
<button
type="button"
onClick={clearFilters}
@@ -1145,6 +1252,10 @@ export default function Tribe() {
)}
</div>
+ <div className="mb-3">
+ <StatusFilterBar statusFilter={statusFilter} onChange={setStatusFilter} />
+ </div>
+
{contacts.length === 0 ? (
<EmptyState onNew={startNewRelationship} />
) : (
@@ -1204,6 +1315,8 @@ export default function Tribe() {
<OutreachQueue />
<CareQueue
contacts={contacts}
+ statusFilter={statusFilter}
+ onStatusFilterChange={setStatusFilter}
onSelect={(contact) => { selectContact(contact); setActiveTab('circle'); }}
onLogTouch={logTouch}
onNew={startNewRelationship}
diff --git a/client/src/pages/Tribe.test.jsx b/client/src/pages/Tribe.test.jsx
index da1ecaee49..01b1199403 100644
--- a/client/src/pages/Tribe.test.jsx
+++ b/client/src/pages/Tribe.test.jsx
@@ -29,9 +29,23 @@ const renderAt = (entry) =>
</MemoryRouter>
);
+const isoDaysAgo = (days) => {
+ const date = new Date();
+ date.setDate(date.getDate() - days);
+ return date.toISOString().slice(0, 10);
+};
+
+// Obviously-fake people covering each cadence state.
+const PEOPLE = [
+ { id: 'p1', name: 'Example Person', ring: 'tribe', cadenceDays: 45, lastContact: isoDaysAgo(200) }, // overdue
+ { id: 'p2', name: 'Sample Neighbor', ring: 'core', cadenceDays: 21, lastContact: isoDaysAgo(18) }, // soon (3d left)
+ { id: 'p3', name: 'Placeholder Pal', ring: 'tribe', cadenceDays: 45, lastContact: isoDaysAgo(1) }, // steady
+];
+
describe('Tribe deep-linkable tabs', () => {
beforeEach(() => {
api.getTribePeople.mockClear();
+ api.getTribePeople.mockResolvedValue({ people: [] });
// localStorage is used for the legacy-import path; keep it empty.
window.localStorage.clear();
});
@@ -42,25 +56,29 @@ describe('Tribe deep-linkable tabs', () => {
expect(await screen.findByText('Energy Mix')).toBeTruthy();
});
- it('falls back to the default Circle tab for an unknown tab value', async () => {
+ it('falls back to the default Care Queue tab for an unknown tab value', async () => {
+ api.getTribePeople.mockResolvedValue({ people: PEOPLE });
renderAt('/tribe?tab=bogus');
- // The Circle tab owns the "Search relationships" filter input.
- expect(await screen.findByPlaceholderText('Search relationships')).toBeTruthy();
+ // The Care Queue leads with the care filter bar and Touch buttons; the
+ // Circle tab's search field is not on the first screen.
+ expect(await screen.findByRole('group', { name: 'Care filter' })).toBeTruthy();
+ expect(screen.getAllByRole('button', { name: /Touch/ }).length).toBeGreaterThan(0);
+ expect(screen.queryByPlaceholderText('Search relationships')).toBeNull();
});
it('writes the active tab to the URL when a tab is selected', async () => {
renderAt('/tribe');
- await screen.findByPlaceholderText('Search relationships');
+ await screen.findByRole('tab', { name: /Focus/i });
fireEvent.click(screen.getByRole('tab', { name: /Focus/i }));
await waitFor(() =>
expect(screen.getByTestId('location').textContent).toBe('/tribe?tab=focus')
);
});
- it('omits the default tab from the URL when returning to Circle', async () => {
+ it('omits the default tab from the URL when returning to the Care Queue', async () => {
renderAt('/tribe?tab=focus');
await screen.findByText('Energy Mix');
- fireEvent.click(screen.getByRole('tab', { name: /Circle/i }));
+ fireEvent.click(screen.getByRole('tab', { name: /Care Queue/i }));
await waitFor(() =>
expect(screen.getByTestId('location').textContent).toBe('/tribe')
);
@@ -68,13 +86,60 @@ describe('Tribe deep-linkable tabs', () => {
it('preserves a non-default tab when the Add action fires a functional update', async () => {
// "Add" calls startNewRelationship, which uses a functional setActiveTab
- // updater that keeps the current tab unless it is focus/map. On Care it must
- // resolve against the fresh URL and stay on care — not fall back to circle.
- renderAt('/tribe?tab=care');
+ // updater that keeps the current tab unless it is focus/map. On Circle it must
+ // resolve against the fresh URL and stay on circle — not fall back to care.
+ renderAt('/tribe?tab=circle');
await screen.findByRole('button', { name: 'Add' });
fireEvent.click(screen.getByRole('button', { name: 'Add' }));
await waitFor(() =>
- expect(screen.getByTestId('location').textContent).toBe('/tribe?tab=care')
+ expect(screen.getByTestId('location').textContent).toBe('/tribe?tab=circle')
+ );
+ });
+});
+
+describe('Tribe care filter', () => {
+ beforeEach(() => {
+ api.getTribePeople.mockClear();
+ api.getTribePeople.mockResolvedValue({ people: PEOPLE });
+ window.localStorage.clear();
+ });
+
+ it('filters the care queue to overdue people when the Needs Care tile is clicked', async () => {
+ renderAt('/tribe');
+ await screen.findByText('Example Person');
+ fireEvent.click(screen.getByRole('button', { name: /^Needs Care \d/ }));
+ await waitFor(() =>
+ expect(screen.getByTestId('location').textContent).toBe('/tribe?status=overdue')
);
+ expect(screen.getByText('Example Person')).toBeTruthy();
+ expect(screen.queryByText('Placeholder Pal')).toBeNull();
+ expect(screen.queryByText('Sample Neighbor')).toBeNull();
+ });
+
+ it('clears the filter when the active tile is clicked again', async () => {
+ renderAt('/tribe?status=overdue');
+ await screen.findByText('Example Person');
+ fireEvent.click(screen.getByRole('button', { name: /^Needs Care \d/ }));
+ await waitFor(() =>
+ expect(screen.getByTestId('location').textContent).toBe('/tribe')
+ );
+ expect(await screen.findByText('Placeholder Pal')).toBeTruthy();
+ });
+
+ it('routes the Coming Up tile into the care tab from another tab', async () => {
+ renderAt('/tribe?tab=circle');
+ await screen.findByPlaceholderText('Search relationships');
+ fireEvent.click(screen.getByRole('button', { name: /^Coming Up \d/ }));
+ await waitFor(() =>
+ expect(screen.getByTestId('location').textContent).toBe('/tribe?status=soon')
+ );
+ expect(await screen.findByText('Sample Neighbor')).toBeTruthy();
+ expect(screen.queryByText('Example Person')).toBeNull();
+ });
+
+ it('applies a deep-linked status filter to the Circle roster', async () => {
+ renderAt('/tribe?tab=circle&status=overdue');
+ expect(await screen.findByText('Example Person')).toBeTruthy();
+ expect(screen.queryByText('Placeholder Pal')).toBeNull();
});
});