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

1.3 KB
Raw Blame
/**
 * Remove the retired Activity by Hour widget from every persisted dashboard
 * layout. The system runs around the clock, so the heatmap carried no signal.
 */

import { readLayoutsDoc, writeLayoutsDoc } from './_lib.js';

const LABEL = 'migration 423';
const WIDGET_ID = 'hourly-activity';

function removeFromLayout(layout) {
  if (!layout || !Array.isArray(layout.widgets)) return false;
  const widgets = layout.widgets.filter((id) => id !== WIDGET_ID);
  const existingGrid = Array.isArray(layout.grid) ? layout.grid : [];
  const grid = existingGrid.filter((item) => item?.id !== WIDGET_ID);
  if (widgets.length === layout.widgets.length && grid.length === existingGrid.length) return false;

  layout.widgets = widgets;
  layout.grid = grid;
  return true;
}

export default {
  async up({ rootDir }) {
    const result = await readLayoutsDoc({ rootDir, label: LABEL });
    if (!result.ok) return { updated: 0, reason: result.reason };
    const { doc, path } = result;
    let updated = 0;
    for (const layout of doc.layouts) {
      if (removeFromLayout(layout)) updated += 1;
    }
    if (updated === 0) return { updated: 0, reason: 'already-applied' };
    await writeLayoutsDoc(path, doc);
    console.log(`📦 ${LABEL}: removed Activity by Hour widget from ${updated} dashboard layout(s).`);
    return { updated };
  },
};