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: remove the redundant Suggested widget-chip bar from the Dashboard (#5320)

[._.]/ Adam Eivy8fc846fec0a6
diff --git a/client/src/components/dashboard/WidgetSuggestions.jsx b/client/src/components/dashboard/WidgetSuggestions.jsx
deleted file mode 100644
index c649f89b99..0000000000
--- a/client/src/components/dashboard/WidgetSuggestions.jsx
+++ /dev/null
@@ -1,76 +0,0 @@
-import { useMemo, useState } from 'react';
-import { Plus, X } from 'lucide-react';
-import { WIDGETS } from './widgetRegistry.jsx';
-
-// Surfaces "Add <Widget>?" chips for widgets whose data source is populated
-// (gate(state) returns true) but that aren't in `presentWidgetIds`.
-// Dismissal is per-mount; persistence is deferred until the suggestion
-// catalog outgrows the 3 gated widgets we ship today.
-export default function WidgetSuggestions({ presentWidgetIds, dashboardState, onAdd }) {
- const [dismissed, setDismissed] = useState(() => new Set());
- // Only one in-flight save at a time. Without this, two rapid clicks each
- // compute their merge from the same stale `presentWidgetIds`, and the
- // second PUT's payload drops the first added widget. Gating on submission
- // forces the second click to wait for the parent's `presentWidgetIds` to
- // refresh after the first save resolves.
- const [submitting, setSubmitting] = useState(false);
-
- const suggestions = useMemo(() => {
- if (!Array.isArray(presentWidgetIds)) return [];
- const present = new Set(presentWidgetIds);
- return WIDGETS.filter((w) => {
- if (!w.gate) return false;
- if (present.has(w.id)) return false;
- if (dismissed.has(w.id)) return false;
- return Boolean(w.gate(dashboardState));
- });
- }, [presentWidgetIds, dashboardState, dismissed]);
-
- if (suggestions.length === 0) return null;
-
- const dismiss = (id) => setDismissed((prev) => {
- const next = new Set(prev);
- next.add(id);
- return next;
- });
-
- const add = (id) => {
- if (submitting) return;
- setSubmitting(true);
- Promise.resolve(onAdd(id))
- .catch(() => {})
- .finally(() => setSubmitting(false));
- };
-
- return (
- <div className="rounded-lg border border-port-border bg-port-card/60 px-3 py-2">
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-xs text-gray-400 uppercase tracking-wide pr-1">Suggested</span>
- {suggestions.map((w) => (
- <span key={w.id} className="inline-flex items-center gap-1 rounded-full border border-port-accent/40 bg-port-accent/10 pl-2 pr-1 py-0.5 text-xs text-gray-200">
- <button
- type="button"
- onClick={() => add(w.id)}
- disabled={submitting}
- className="inline-flex items-center gap-1 text-port-accent hover:text-white disabled:opacity-50 disabled:cursor-wait"
- aria-label={`Add ${w.label} to layout`}
- >
- <Plus size={12} aria-hidden="true" />
- <span>Add {w.label}?</span>
- </button>
- <button
- type="button"
- onClick={() => dismiss(w.id)}
- disabled={submitting}
- className="p-0.5 rounded text-gray-500 hover:text-gray-300 disabled:opacity-50"
- aria-label={`Dismiss ${w.label} suggestion`}
- title="Hide this suggestion"
- >
- <X size={11} aria-hidden="true" />
- </button>
- </span>
- ))}
- </div>
- </div>
- );
-}
diff --git a/client/src/components/dashboard/WidgetSuggestions.test.jsx b/client/src/components/dashboard/WidgetSuggestions.test.jsx
deleted file mode 100644
index 82c490f715..0000000000
--- a/client/src/components/dashboard/WidgetSuggestions.test.jsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import { describe, it, expect, vi } from 'vitest';
-import { render, screen, fireEvent, act } from '@testing-library/react';
-import WidgetSuggestions from './WidgetSuggestions';
-import { WIDGETS_BY_ID } from './widgetRegistry.jsx';
-
-// `quick-stats` ships with gate: (s) => s.apps.length > 0 — a deterministic
-// fixture lets us exercise the "data populated but widget missing" path
-// without mocking the registry.
-
-describe('WidgetSuggestions', () => {
- const emptyState = { apps: [], usage: null };
- const populatedState = {
- apps: [{ id: 'a1', name: 'app', overallStatus: 'online' }],
- usage: { currentStreak: 5, longestStreak: 5, hourlyActivity: [0, 0, 1, 0] },
- };
-
- it('gates the Daily POST registry entry on instance participation', () => {
- const gate = WIDGETS_BY_ID['daily-post'].gate;
-
- expect(gate({ instanceFeatures: { features: [{ id: 'post', enabled: false }] } })).toBe(false);
- expect(gate({ instanceFeatures: { features: [{ id: 'post', enabled: true }] } })).toBe(true);
- expect(gate({})).toBe(false);
- expect(gate({ instanceFeatures: null })).toBe(false);
- });
-
- it('keeps the Apps Grid hidden until its first read completes', () => {
- const gate = WIDGETS_BY_ID.apps.gate;
-
- expect(gate({ apps: [], appsLoading: true })).toBe(false);
- expect(gate({ apps: [], appsLoading: false })).toBe(true);
- });
-
- it('renders nothing when every gated widget is already present', () => {
- const { container } = render(
- <WidgetSuggestions
- presentWidgetIds={['quick-stats', 'activity-streak', 'hourly-activity']}
- dashboardState={populatedState}
- onAdd={() => {}}
- />
- );
- expect(container).toBeEmptyDOMElement();
- });
-
- it('renders nothing when no gated widget has data', () => {
- const { container } = render(
- <WidgetSuggestions presentWidgetIds={[]} dashboardState={emptyState} onAdd={() => {}} />
- );
- expect(container).toBeEmptyDOMElement();
- });
-
- it('suggests a missing-but-data-populated widget', () => {
- render(<WidgetSuggestions presentWidgetIds={[]} dashboardState={populatedState} onAdd={() => {}} />);
- expect(screen.getByText(/Quick Stats/)).toBeDefined();
- });
-
- it('calls onAdd with only the widget id — no layout shape passed', async () => {
- const onAdd = vi.fn().mockResolvedValue();
- render(<WidgetSuggestions presentWidgetIds={['cos']} dashboardState={populatedState} onAdd={onAdd} />);
- fireEvent.click(screen.getByLabelText('Add Quick Stats to layout'));
- expect(onAdd).toHaveBeenCalledTimes(1);
- expect(onAdd).toHaveBeenCalledWith('quick-stats');
- expect(onAdd.mock.calls[0]).toHaveLength(1);
- // add() clears `submitting` in a .finally() microtask after onAdd resolves —
- // flush it inside act() so that setState doesn't land after the test returns.
- await act(async () => {});
- });
-
- it('dismissing a suggestion hides it for the lifetime of the mount', () => {
- render(<WidgetSuggestions presentWidgetIds={[]} dashboardState={populatedState} onAdd={() => {}} />);
- expect(screen.queryByText(/Quick Stats/)).not.toBeNull();
- fireEvent.click(screen.getByLabelText('Dismiss Quick Stats suggestion'));
- expect(screen.queryByText(/Quick Stats/)).toBeNull();
- });
-
- it('throttles to one in-flight add — rapid second click is dropped', async () => {
- let resolveFirst;
- const onAdd = vi.fn().mockImplementation(() => new Promise((resolve) => { resolveFirst = resolve; }));
- render(<WidgetSuggestions presentWidgetIds={[]} dashboardState={populatedState} onAdd={onAdd} />);
- // Both Quick Stats AND Activity Streak gate true on populatedState.
- fireEvent.click(screen.getByLabelText('Add Quick Stats to layout'));
- fireEvent.click(screen.getByLabelText('Add Activity Streak to layout'));
- // Only the first click fired onAdd; without the throttle, both would
- // fire with stale presentWidgetIds and the second PUT would drop the
- // first added widget.
- expect(onAdd).toHaveBeenCalledTimes(1);
- expect(onAdd).toHaveBeenCalledWith('quick-stats');
- // Resolving the in-flight add clears `submitting` in a .finally() microtask;
- // flush it inside act() so the setState is wrapped.
- await act(async () => { resolveFirst(); });
- });
-});
diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsx
index 972d593e81..c462f0db1a 100644
--- a/client/src/pages/Dashboard.jsx
+++ b/client/src/pages/Dashboard.jsx
@@ -4,7 +4,6 @@ import BrailleSpinner from '../components/BrailleSpinner';
import PageSkeleton from '../components/ui/PageSkeleton';
import LayoutPicker from '../components/dashboard/LayoutPicker';
import LayoutEditor from '../components/dashboard/LayoutEditor';
-import WidgetSuggestions from '../components/dashboard/WidgetSuggestions';
import DashboardGrid, { readingOrderIds, reconcileGrid, synthesizeGrid } from '../components/dashboard/DashboardGrid.jsx';
import { WIDGETS_BY_ID, FALLBACK_LAYOUT } from '../components/dashboard/widgetRegistry.jsx';
import WidgetSkeleton from '../components/dashboard/WidgetSkeleton';
@@ -73,17 +72,6 @@ export default function Dashboard() {
// viewport, so the two disagree in a ~30px band and the hint would describe
// handles that aren't on screen.
const [gridIsMobile, setGridIsMobile] = useState(false);
- // Widget just added from a suggestion chip, so the render pass that lands it
- // in the grid can scroll it into view (new widgets append at the bottom —
- // off-screen on the single-column mobile stack, which made the suggestion
- // look like it did nothing when it was actually added). Scoped to the layout
- // it was added on ({ widgetId, layoutId }) so a layout switch mid-save can't
- // scroll to an unrelated widget that happens to exist in the new layout.
- const [pendingScroll, setPendingScroll] = useState(null);
- // Mirrors activeLayoutId for reads inside the async onAdd handler, whose
- // closure captured a possibly-stale activeLayout — lets it skip arming the
- // scroll when the user switched layouts while the add was still saving.
- const activeLayoutIdRef = useRef(null);
// Dashboard widget gates intentionally read the raw list: unlike navigation,
// a failed feature read must fail closed and reserve no POST widget cell.
const { features: instanceFeatureList } = useInstanceFeatures();
@@ -290,13 +278,8 @@ export default function Dashboard() {
// Cancel grid edit mode whenever the user switches layouts so unsaved
// positional edits don't bleed across layouts.
useEffect(() => {
- activeLayoutIdRef.current = activeLayoutId;
setEditingGrid(false);
setDraftGrid(null);
- // Drop any pending "scroll the just-added widget into view" — it was armed
- // against the previous layout, so honoring it after a switch could scroll
- // to an unrelated widget (or an existing cell) in the new layout.
- setPendingScroll(null);
}, [activeLayoutId]);
// Stable identity so DashboardGrid's memoized cells actually bail out — a
@@ -312,20 +295,6 @@ export default function Dashboard() {
);
}, [dashboardState]);
- // Once a just-added widget lands in the rendered grid, scroll it into view
- // so the "Add <widget>?" suggestion produces a visible result instead of a
- // chip that silently vanishes.
- useEffect(() => {
- if (!pendingScroll) return;
- // Only honor the scroll on the layout the widget was actually added to —
- // a save that resolved after a layout switch must not scroll the new one.
- if (pendingScroll.layoutId !== activeLayout?.id) return;
- if (!renderGrid.some((item) => item.id === pendingScroll.widgetId)) return;
- const el = document.querySelector(`[data-widget-id="${CSS.escape(pendingScroll.widgetId)}"]`);
- el?.scrollIntoView({ behavior: 'smooth', block: 'center' });
- setPendingScroll(null);
- }, [pendingScroll, renderGrid, activeLayout]);
-
const startGridEdit = () => {
setDraftGrid(renderGrid);
setEditingGrid(true);
@@ -545,27 +514,6 @@ export default function Dashboard() {
</div>
)}
- {!editingGrid && activeLayout && activeLayout.id !== FALLBACK_LAYOUT.id && (
- <WidgetSuggestions
- presentWidgetIds={activeLayout.widgets}
- dashboardState={dashboardState}
- onAdd={async (widgetId) => {
- const layoutId = activeLayout.id;
- await saveLayout({
- id: layoutId,
- name: activeLayout.name,
- widgets: [...activeLayout.widgets, widgetId],
- activateWindow: activeLayout.activateWindow ?? null,
- });
- toast.success(`Added ${WIDGETS_BY_ID[widgetId]?.label ?? 'widget'} to your dashboard`);
- // Only arm the scroll if this layout is still active — a switch
- // while the save was in flight means the added widget isn't on
- // screen, so arming would fire a stray scroll on returning here.
- if (activeLayoutIdRef.current === layoutId) setPendingScroll({ widgetId, layoutId });
- }}
- />
- )}
-
{visibleWidgets.length > 0 && (
<>
{editingGrid && (