[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KKE9WJG20BYDHYYHN28KTY":3,"skill-same:01M6KKE9WJG20BYDHYYHN28KTY":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":13,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":48,"updatedAt":49,"install":50,"resources":63},"01M6KKE9WJG20BYDHYYHN28KTY","panel-component-aggregator",null,"Dashboard panel component pattern for aggregator\u002Fsummary panels that accept pushed partial data updates via updateData(), defer rendering until first data arrives, and incrementally re-render metrics without re-fetching — ideal for panels that synthesize data already fetched by other panels.","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fpanel-component-aggregator\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"component","panel component","panel component aggregator","aggregator","panel","re-render","dashboard","for","updates","re","render","rendering","via","panels","pattern","synthesize","summary","first","data","metrics","2026-11-10 10:12:30",false,"---\nname: panel-component-aggregator\ndescription: Dashboard panel component pattern for aggregator\u002Fsummary panels that accept pushed partial data updates via updateData(), defer rendering until first data arrives, and incrementally re-render metrics without re-fetching — ideal for panels that synthesize data already fetched by other panels.\n---\n\n# Aggregator Panel Component Pattern\n\nCreate **aggregator** dashboard panel components using **vanilla TypeScript** (no framework, no JSX).\nAn aggregator panel does **not** fetch data itself. Instead, it receives partial data pushes from sibling panels (or a coordinator) via `updateData(partial)`, defers its first render until enough data has arrived, and re-renders incrementally on each subsequent push.\n\nThis skill is self-contained. It covers the base `Panel` class, the `AggregatorPanel` generic base class, and a concrete example (`SummaryPanel`).\n\n---\n\n## When to Use This Pattern\n\n| Use case | Fetching Panel | Aggregator Panel |\n|---|---|---|\n| Panel owns its own API endpoint | yes | no |\n| Panel summarises data from multiple sources | no | yes |\n| Data arrives asynchronously from siblings | no | yes |\n| Re-renders on each push without extra network calls | no | yes |\n\n---\n\n## Architecture Overview\n\n```\nPanel (base class)\n└── AggregatorPanel\u003CTData> (generic aggregator base)\n    ├── partialData: Partial\u003CTData>         — accumulated pushed fields\n    ├── receivedKeys: Set\u003Ckeyof TData>      — tracks which keys have arrived\n    ├── requiredKeys: (keyof TData)[]       — keys needed before first render\n    ├── lastUpdated: Map\u003Ckeyof TData, number> — staleness timestamps\n    └── SummaryPanel (concrete example)\n```\n\nData flow:\n\n```\nStockPanel ──pushes──► coordinator.push('stocks', quotes)\nEmailPanel ──pushes──► coordinator.push('emails', messages)\n                               │\n                    AggregatorPanel.updateData({ stocks, emails })\n                               │\n                    ┌──────────▼──────────┐\n                    │  enough data yet?   │\n                    │  no  → showPending  │\n                    │  yes → render()     │\n                    └─────────────────────┘\n```\n\n---\n\n## Base Panel Class\n\nCreate `src\u002Fcomponents\u002FPanel.ts`:\n\n```typescript\nexport interface PanelOptions {\n  id: string;\n  title: string;\n  showCount?: boolean;\n  className?: string;\n}\n\nexport class Panel {\n  protected element: HTMLElement;\n  protected content: HTMLElement;\n  protected header: HTMLElement;\n  protected countEl: HTMLElement | null = null;\n  protected panelId: string;\n  private _fetching = false;\n\n  constructor(options: PanelOptions) {\n    this.panelId = options.id;\n    this.element = document.createElement('div');\n    this.element.className = `panel ${options.className || ''}`.trim();\n    this.element.dataset.panel = options.id;\n\n    \u002F\u002F Header\n    this.header = document.createElement('div');\n    this.header.className = 'panel-header';\n\n    const headerLeft = document.createElement('div');\n    headerLeft.className = 'panel-header-left';\n\n    const title = document.createElement('span');\n    title.className = 'panel-title';\n    title.textContent = options.title;\n    headerLeft.appendChild(title);\n    this.header.appendChild(headerLeft);\n\n    if (options.showCount) {\n      this.countEl = document.createElement('span');\n      this.countEl.className = 'panel-count';\n      this.countEl.textContent = '0';\n      this.header.appendChild(this.countEl);\n    }\n\n    this.content = document.createElement('div');\n    this.content.className = 'panel-content';\n    this.content.id = `${options.id}Content`;\n\n    this.element.appendChild(this.header);\n    this.element.appendChild(this.content);\n  }\n\n  public getElement(): HTMLElement { return this.element; }\n\n  public showLoading(message = 'Loading...'): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-loading\">\n        \u003Cdiv class=\"panel-loading-spinner\">\u003C\u002Fdiv>\n        \u003Cdiv class=\"panel-loading-text\">${message}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n\n  \u002F** Show a \"waiting for data\" placeholder — softer than showLoading *\u002F\n  public showPending(message = 'Waiting for data\\u2026'): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-pending\">\n        \u003Cdiv class=\"panel-pending-text\">${message}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n\n  public showError(message = 'Failed to load', onRetry?: () => void): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-error-state\">\n        \u003Cdiv class=\"panel-error-msg\">${message}\u003C\u002Fdiv>\n        ${onRetry ? '\u003Cbutton class=\"panel-retry-btn\" data-panel-retry>Retry\u003C\u002Fbutton>' : ''}\n      \u003C\u002Fdiv>`;\n    if (onRetry) {\n      this.content.querySelector('[data-panel-retry]')\n        ?.addEventListener('click', onRetry);\n    }\n  }\n\n  public setContent(html: string): void { this.content.innerHTML = html; }\n\n  public setCount(count: number): void {\n    if (this.countEl) this.countEl.textContent = count.toString();\n  }\n\n  public show(): void { this.element.classList.remove('hidden'); }\n  public hide(): void { this.element.classList.add('hidden'); }\n\n  protected setFetching(v: boolean): void { this._fetching = v; }\n  protected get isFetching(): boolean { return this._fetching; }\n\n  public destroy(): void { this.element.remove(); }\n}\n```\n\n---\n\n## AggregatorPanel Base Class\n\nCreate `src\u002Fcomponents\u002FAggregatorPanel.ts`:\n\n```typescript\nimport { Panel, PanelOptions } from '.\u002FPanel';\n\nexport interface AggregatorPanelOptions\u003CTData> extends PanelOptions {\n  \u002F**\n   * Keys that MUST be present before the first render is attempted.\n   * Until all required keys have been received at least once, the panel\n   * shows a pending placeholder.\n   *\u002F\n  requiredKeys: (keyof TData)[];\n\n  \u002F**\n   * How old (ms) a field can be before it is considered stale and a\n   * staleness indicator is shown in the header. Defaults to 5 minutes.\n   *\u002F\n  staleThresholdMs?: number;\n}\n\n\u002F**\n * Base class for panels that aggregate data pushed from other panels\n * rather than fetching independently.\n *\n * Usage:\n *   1. Extend AggregatorPanel\u003CYourDataShape>.\n *   2. Implement render(data: YourDataShape): void.\n *   3. Call updateData(partial) whenever a sibling pushes new data.\n *\u002F\nexport abstract class AggregatorPanel\u003CTData extends Record\u003Cstring, unknown>>\n  extends Panel {\n\n  private partialData: Partial\u003CTData> = {};\n  private receivedKeys = new Set\u003Ckeyof TData>();\n  private readonly requiredKeys: (keyof TData)[];\n  private readonly staleThresholdMs: number;\n  private lastUpdated = new Map\u003Ckeyof TData, number>();\n  private hasRenderedOnce = false;\n\n  constructor(options: AggregatorPanelOptions\u003CTData>) {\n    super(options);\n    this.requiredKeys = options.requiredKeys;\n    this.staleThresholdMs = options.staleThresholdMs ?? 5 * 60 * 1000;\n    \u002F\u002F Show pending placeholder immediately — no spinner, no fetch\n    this.showPending(this.buildPendingMessage());\n  }\n\n  \u002F\u002F ── Public API ──────────────────────────────────────────────────────────\n\n  \u002F**\n   * Accept a partial data push. Merges incoming fields into accumulated\n   * state, timestamps each updated key, and either triggers the first\n   * render (if required keys are now satisfied) or re-renders incrementally.\n   *\u002F\n  public updateData(partial: Partial\u003CTData>): void {\n    for (const key of Object.keys(partial) as (keyof TData)[]) {\n      this.partialData[key] = partial[key];\n      this.receivedKeys.add(key);\n      this.lastUpdated.set(key, Date.now());\n    }\n\n    if (!this.hasRequiredData()) {\n      this.showPending(this.buildPendingMessage());\n      return;\n    }\n\n    \u002F\u002F All required keys present — safe to cast\n    try {\n      this.render(this.partialData as TData);\n      this.hasRenderedOnce = true;\n      this.updateStalenessIndicators();\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      this.showError(`Render error: ${message}`, () => {\n        this.updateData({});\n      });\n    }\n  }\n\n  \u002F** Returns true if every requiredKey has been received at least once. *\u002F\n  public hasRequiredData(): boolean {\n    return this.requiredKeys.every(k => this.receivedKeys.has(k));\n  }\n\n  \u002F** Returns the set of required keys that have not yet been received. *\u002F\n  public getMissingKeys(): (keyof TData)[] {\n    return this.requiredKeys.filter(k => !this.receivedKeys.has(k));\n  }\n\n  \u002F** Returns true if a specific key's data is older than staleThresholdMs. *\u002F\n  public isStale(key: keyof TData): boolean {\n    const ts = this.lastUpdated.get(key);\n    if (ts == null) return false;\n    return Date.now() - ts > this.staleThresholdMs;\n  }\n\n  \u002F**\n   * Force-clears accumulated data and reverts to pending state.\n   * Useful when the data source resets (e.g. user logs out).\n   *\u002F\n  public reset(): void {\n    this.partialData = {};\n    this.receivedKeys.clear();\n    this.lastUpdated.clear();\n    this.hasRenderedOnce = false;\n    this.showPending(this.buildPendingMessage());\n  }\n\n  \u002F\u002F ── Protected helpers ───────────────────────────────────────────────────\n\n  \u002F**\n   * Subclasses MUST implement this. Called every time updateData() receives\n   * a push after required keys are satisfied. `data` is guaranteed to\n   * contain all requiredKeys.\n   *\u002F\n  protected abstract render(data: TData): void;\n\n  \u002F**\n   * Returns the accumulated partial snapshot. Useful inside render() for\n   * optional (non-required) keys.\n   *\u002F\n  protected getSnapshot(): Partial\u003CTData> {\n    return { ...this.partialData };\n  }\n\n  \u002F**\n   * True on the first render call, false on subsequent updates.\n   * Use to decide between full DOM replacement vs. in-place patch.\n   *\u002F\n  protected get isFirstRender(): boolean {\n    return !this.hasRenderedOnce;\n  }\n\n  \u002F\u002F ── Private helpers ─────────────────────────────────────────────────────\n\n  private buildPendingMessage(): string {\n    const missing = this.getMissingKeys() as string[];\n    if (missing.length === 0) return 'Processing\\u2026';\n    return `Waiting for: ${missing.join(', ')}`;\n  }\n\n  private updateStalenessIndicators(): void {\n    const staleKeys = this.requiredKeys.filter(k => this.isStale(k));\n    const indicator = this.element.querySelector('.panel-stale-indicator');\n    if (staleKeys.length > 0) {\n      const msg = `Stale data: ${(staleKeys as string[]).join(', ')}`;\n      if (indicator) {\n        indicator.textContent = msg;\n      } else {\n        const el = document.createElement('div');\n        el.className = 'panel-stale-indicator';\n        el.textContent = msg;\n        this.header.appendChild(el);\n      }\n    } else {\n      indicator?.remove();\n    }\n  }\n}\n```\n\n---\n\n## Concrete Example: SummaryPanel\n\nCreate `src\u002Fcomponents\u002FSummaryPanel.ts`:\n\n```typescript\nimport { AggregatorPanel } from '.\u002FAggregatorPanel';\nimport { StockQuote } from '..\u002Fservices\u002Fstock-service';\nimport { EmailMessage } from '..\u002Fservices\u002Femail-service';\nimport { CalendarEvent } from '..\u002Fservices\u002Fcalendar-service';\n\ninterface SummaryData {\n  stocks: StockQuote[];\n  emails: EmailMessage[];\n  events: CalendarEvent[];\n}\n\nexport class SummaryPanel extends AggregatorPanel\u003CSummaryData> {\n  constructor() {\n    super({\n      id: 'summary',\n      title: 'Daily Summary',\n      className: 'panel-wide',\n      showCount: true,\n      \u002F\u002F Render as soon as stocks + emails arrive; events are optional bonus\n      requiredKeys: ['stocks', 'emails'],\n      staleThresholdMs: 3 * 60 * 1000,\n    });\n  }\n\n  protected render(data: SummaryData): void {\n    const snapshot = this.getSnapshot();\n\n    const unread  = data.emails.filter(e => !e.read).length;\n    const gainers = data.stocks.filter(q => (q.change ?? 0) > 0).length;\n    const losers  = data.stocks.filter(q => (q.change ?? 0) \u003C 0).length;\n\n    \u002F\u002F Optional key — may not have arrived yet\n    const upcomingCount = snapshot.events\n      ? snapshot.events.filter(ev => new Date(ev.start) > new Date()).length\n      : null;\n\n    const eventsHtml = upcomingCount != null\n      ? `\u003Cdiv class=\"summary-metric\" data-metric=\"events\">\n           \u003Cspan class=\"summary-metric-label\">Upcoming events\u003C\u002Fspan>\n           \u003Cspan class=\"summary-metric-value\">${upcomingCount}\u003C\u002Fspan>\n         \u003C\u002Fdiv>`\n      : '';\n\n    if (this.isFirstRender) {\n      \u002F\u002F Full DOM build on first render\n      this.setContent(`\n        \u003Cdiv class=\"summary-metrics\">\n          \u003Cdiv class=\"summary-metric\" data-metric=\"unread\">\n            \u003Cspan class=\"summary-metric-label\">Unread emails\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value\">${unread}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          \u003Cdiv class=\"summary-metric\" data-metric=\"gainers\">\n            \u003Cspan class=\"summary-metric-label\">Stocks up\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value positive\">${gainers}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          \u003Cdiv class=\"summary-metric\" data-metric=\"losers\">\n            \u003Cspan class=\"summary-metric-label\">Stocks down\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value negative\">${losers}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          ${eventsHtml}\n        \u003C\u002Fdiv>\n      `);\n    } else {\n      \u002F\u002F Incremental patch — avoid full DOM thrash on subsequent pushes\n      this.patchMetric('unread', unread);\n      this.patchMetric('gainers', gainers);\n      this.patchMetric('losers', losers);\n      if (upcomingCount != null) this.patchMetric('events', upcomingCount);\n    }\n\n    this.setCount(data.emails.length + data.stocks.length);\n  }\n\n  \u002F** Update a single metric value in-place *\u002F\n  private patchMetric(name: string, value: number): void {\n    const el = this.content.querySelector(\n      `[data-metric=\"${name}\"] .summary-metric-value`\n    );\n    if (el) el.textContent = String(value);\n  }\n}\n```\n\n---\n\n## Coordinator \u002F Push Pattern\n\nCreate `src\u002Fservices\u002Fpanel-coordinator.ts`:\n\n```typescript\nimport { SummaryPanel } from '..\u002Fcomponents\u002FSummaryPanel';\n\n\u002F**\n * Lightweight pub\u002Fsub coordinator. Fetching panels call coordinator.push()\n * after each successful render; aggregator panels receive those updates.\n *\u002F\nexport class PanelCoordinator {\n  private summaryPanel: SummaryPanel;\n\n  constructor(summaryPanel: SummaryPanel) {\n    this.summaryPanel = summaryPanel;\n  }\n\n  push\u003CK extends 'stocks' | 'emails' | 'events'>(\n    key: K,\n    value: unknown\n  ): void {\n    this.summaryPanel.updateData({ [key]: value } as any);\n  }\n}\n```\n\nIn your fetching panels, call `coordinator.push()` after each successful render:\n\n```typescript\n\u002F\u002F Inside StockPanel.fetchData(), after this.render(quotes):\ncoordinator.push('stocks', quotes);\n\n\u002F\u002F Inside EmailPanel.fetchData(), after this.render(messages):\ncoordinator.push('emails', messages);\n```\n\n---\n\n## Key Patterns\n\n1. **Constructor** calls `super()` with `requiredKeys` — the minimum fields needed before the first render.\n2. **updateData(partial)** is the only public ingestion point. It merges, timestamps, and either shows a pending placeholder or triggers `render()`.\n3. **render(data)** receives a fully-typed snapshot; use `this.getSnapshot()` for optional keys.\n4. **isFirstRender** lets you choose between a full DOM replace (first time) vs. incremental in-place patch (subsequent pushes) to avoid unnecessary reflow.\n5. **Staleness indicators** are automatically injected into the header when a key's last-update timestamp exceeds `staleThresholdMs`.\n6. **reset()** clears all state and reverts to pending — call it on session logout or data source disconnect.\n7. Aggregator panels never call `fetch()` or `showLoading()` — they call `showPending()` until required data arrives.\n8. The coordinator is a thin pub\u002Fsub shim; replace with EventEmitter, RxJS Subject, or your app's store if available.\n\n---\n\n## Aggregator vs Fetching Panel Checklist\n\n| Concern | Fetching Panel | Aggregator Panel |\n|---|---|---|\n| Network call | `fetchWithRetry(url)` | none |\n| Initial state | `showLoading()` in constructor | `showPending()` in constructor |\n| Data ingestion | internal async fetch | `updateData(partial)` |\n| First render gate | none | `hasRequiredData()` |\n| Re-render strategy | full replace | incremental patch preferred |\n| Staleness | timer-based refetch | automatic header indicator |\n| `destroy()` | clear interval + super | super only (no timers to clear) |\n\n---\n\n## TypeScript Strict-Mode Notes\n\n- `TData extends Record\u003Cstring, unknown>` ensures key iteration is safe.\n- `Object.keys(partial) as (keyof TData)[]` is safe because `partial` is `Partial\u003CTData>`.\n- The `as TData` cast in `this.render(this.partialData as TData)` is guarded by `hasRequiredData()` — a runtime guarantee backing the compile-time assertion.\n- If your project enables `exactOptionalPropertyTypes`, declare optional aggregated sources as `key?: T | undefined` in `TData`.\n","# Aggregator Panel Component Pattern\n\nCreate **aggregator** dashboard panel components using **vanilla TypeScript** (no framework, no JSX).\nAn aggregator panel does **not** fetch data itself. Instead, it receives partial data pushes from sibling panels (or a coordinator) via `updateData(partial)`, defers its first render until enough data has arrived, and re-renders incrementally on each subsequent push.\n\nThis skill is self-contained. It covers the base `Panel` class, the `AggregatorPanel` generic base class, and a concrete example (`SummaryPanel`).\n\n---\n\n## When to Use This Pattern\n\n| Use case | Fetching Panel | Aggregator Panel |\n|---|---|---|\n| Panel owns its own API endpoint | yes | no |\n| Panel summarises data from multiple sources | no | yes |\n| Data arrives asynchronously from siblings | no | yes |\n| Re-renders on each push without extra network calls | no | yes |\n\n---\n\n## Architecture Overview\n\n```\nPanel (base class)\n└── AggregatorPanel\u003CTData> (generic aggregator base)\n    ├── partialData: Partial\u003CTData>         — accumulated pushed fields\n    ├── receivedKeys: Set\u003Ckeyof TData>      — tracks which keys have arrived\n    ├── requiredKeys: (keyof TData)[]       — keys needed before first render\n    ├── lastUpdated: Map\u003Ckeyof TData, number> — staleness timestamps\n    └── SummaryPanel (concrete example)\n```\n\nData flow:\n\n```\nStockPanel ──pushes──► coordinator.push('stocks', quotes)\nEmailPanel ──pushes──► coordinator.push('emails', messages)\n                               │\n                    AggregatorPanel.updateData({ stocks, emails })\n                               │\n                    ┌──────────▼──────────┐\n                    │  enough data yet?   │\n                    │  no  → showPending  │\n                    │  yes → render()     │\n                    └─────────────────────┘\n```\n\n---\n\n## Base Panel Class\n\nCreate `src\u002Fcomponents\u002FPanel.ts`:\n\n```typescript\nexport interface PanelOptions {\n  id: string;\n  title: string;\n  showCount?: boolean;\n  className?: string;\n}\n\nexport class Panel {\n  protected element: HTMLElement;\n  protected content: HTMLElement;\n  protected header: HTMLElement;\n  protected countEl: HTMLElement | null = null;\n  protected panelId: string;\n  private _fetching = false;\n\n  constructor(options: PanelOptions) {\n    this.panelId = options.id;\n    this.element = document.createElement('div');\n    this.element.className = `panel ${options.className || ''}`.trim();\n    this.element.dataset.panel = options.id;\n\n    \u002F\u002F Header\n    this.header = document.createElement('div');\n    this.header.className = 'panel-header';\n\n    const headerLeft = document.createElement('div');\n    headerLeft.className = 'panel-header-left';\n\n    const title = document.createElement('span');\n    title.className = 'panel-title';\n    title.textContent = options.title;\n    headerLeft.appendChild(title);\n    this.header.appendChild(headerLeft);\n\n    if (options.showCount) {\n      this.countEl = document.createElement('span');\n      this.countEl.className = 'panel-count';\n      this.countEl.textContent = '0';\n      this.header.appendChild(this.countEl);\n    }\n\n    this.content = document.createElement('div');\n    this.content.className = 'panel-content';\n    this.content.id = `${options.id}Content`;\n\n    this.element.appendChild(this.header);\n    this.element.appendChild(this.content);\n  }\n\n  public getElement(): HTMLElement { return this.element; }\n\n  public showLoading(message = 'Loading...'): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-loading\">\n        \u003Cdiv class=\"panel-loading-spinner\">\u003C\u002Fdiv>\n        \u003Cdiv class=\"panel-loading-text\">${message}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n\n  \u002F** Show a \"waiting for data\" placeholder — softer than showLoading *\u002F\n  public showPending(message = 'Waiting for data\\u2026'): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-pending\">\n        \u003Cdiv class=\"panel-pending-text\">${message}\u003C\u002Fdiv>\n      \u003C\u002Fdiv>`;\n  }\n\n  public showError(message = 'Failed to load', onRetry?: () => void): void {\n    this.content.innerHTML = `\n      \u003Cdiv class=\"panel-error-state\">\n        \u003Cdiv class=\"panel-error-msg\">${message}\u003C\u002Fdiv>\n        ${onRetry ? '\u003Cbutton class=\"panel-retry-btn\" data-panel-retry>Retry\u003C\u002Fbutton>' : ''}\n      \u003C\u002Fdiv>`;\n    if (onRetry) {\n      this.content.querySelector('[data-panel-retry]')\n        ?.addEventListener('click', onRetry);\n    }\n  }\n\n  public setContent(html: string): void { this.content.innerHTML = html; }\n\n  public setCount(count: number): void {\n    if (this.countEl) this.countEl.textContent = count.toString();\n  }\n\n  public show(): void { this.element.classList.remove('hidden'); }\n  public hide(): void { this.element.classList.add('hidden'); }\n\n  protected setFetching(v: boolean): void { this._fetching = v; }\n  protected get isFetching(): boolean { return this._fetching; }\n\n  public destroy(): void { this.element.remove(); }\n}\n```\n\n---\n\n## AggregatorPanel Base Class\n\nCreate `src\u002Fcomponents\u002FAggregatorPanel.ts`:\n\n```typescript\nimport { Panel, PanelOptions } from '.\u002FPanel';\n\nexport interface AggregatorPanelOptions\u003CTData> extends PanelOptions {\n  \u002F**\n   * Keys that MUST be present before the first render is attempted.\n   * Until all required keys have been received at least once, the panel\n   * shows a pending placeholder.\n   *\u002F\n  requiredKeys: (keyof TData)[];\n\n  \u002F**\n   * How old (ms) a field can be before it is considered stale and a\n   * staleness indicator is shown in the header. Defaults to 5 minutes.\n   *\u002F\n  staleThresholdMs?: number;\n}\n\n\u002F**\n * Base class for panels that aggregate data pushed from other panels\n * rather than fetching independently.\n *\n * Usage:\n *   1. Extend AggregatorPanel\u003CYourDataShape>.\n *   2. Implement render(data: YourDataShape): void.\n *   3. Call updateData(partial) whenever a sibling pushes new data.\n *\u002F\nexport abstract class AggregatorPanel\u003CTData extends Record\u003Cstring, unknown>>\n  extends Panel {\n\n  private partialData: Partial\u003CTData> = {};\n  private receivedKeys = new Set\u003Ckeyof TData>();\n  private readonly requiredKeys: (keyof TData)[];\n  private readonly staleThresholdMs: number;\n  private lastUpdated = new Map\u003Ckeyof TData, number>();\n  private hasRenderedOnce = false;\n\n  constructor(options: AggregatorPanelOptions\u003CTData>) {\n    super(options);\n    this.requiredKeys = options.requiredKeys;\n    this.staleThresholdMs = options.staleThresholdMs ?? 5 * 60 * 1000;\n    \u002F\u002F Show pending placeholder immediately — no spinner, no fetch\n    this.showPending(this.buildPendingMessage());\n  }\n\n  \u002F\u002F ── Public API ──────────────────────────────────────────────────────────\n\n  \u002F**\n   * Accept a partial data push. Merges incoming fields into accumulated\n   * state, timestamps each updated key, and either triggers the first\n   * render (if required keys are now satisfied) or re-renders incrementally.\n   *\u002F\n  public updateData(partial: Partial\u003CTData>): void {\n    for (const key of Object.keys(partial) as (keyof TData)[]) {\n      this.partialData[key] = partial[key];\n      this.receivedKeys.add(key);\n      this.lastUpdated.set(key, Date.now());\n    }\n\n    if (!this.hasRequiredData()) {\n      this.showPending(this.buildPendingMessage());\n      return;\n    }\n\n    \u002F\u002F All required keys present — safe to cast\n    try {\n      this.render(this.partialData as TData);\n      this.hasRenderedOnce = true;\n      this.updateStalenessIndicators();\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      this.showError(`Render error: ${message}`, () => {\n        this.updateData({});\n      });\n    }\n  }\n\n  \u002F** Returns true if every requiredKey has been received at least once. *\u002F\n  public hasRequiredData(): boolean {\n    return this.requiredKeys.every(k => this.receivedKeys.has(k));\n  }\n\n  \u002F** Returns the set of required keys that have not yet been received. *\u002F\n  public getMissingKeys(): (keyof TData)[] {\n    return this.requiredKeys.filter(k => !this.receivedKeys.has(k));\n  }\n\n  \u002F** Returns true if a specific key's data is older than staleThresholdMs. *\u002F\n  public isStale(key: keyof TData): boolean {\n    const ts = this.lastUpdated.get(key);\n    if (ts == null) return false;\n    return Date.now() - ts > this.staleThresholdMs;\n  }\n\n  \u002F**\n   * Force-clears accumulated data and reverts to pending state.\n   * Useful when the data source resets (e.g. user logs out).\n   *\u002F\n  public reset(): void {\n    this.partialData = {};\n    this.receivedKeys.clear();\n    this.lastUpdated.clear();\n    this.hasRenderedOnce = false;\n    this.showPending(this.buildPendingMessage());\n  }\n\n  \u002F\u002F ── Protected helpers ───────────────────────────────────────────────────\n\n  \u002F**\n   * Subclasses MUST implement this. Called every time updateData() receives\n   * a push after required keys are satisfied. `data` is guaranteed to\n   * contain all requiredKeys.\n   *\u002F\n  protected abstract render(data: TData): void;\n\n  \u002F**\n   * Returns the accumulated partial snapshot. Useful inside render() for\n   * optional (non-required) keys.\n   *\u002F\n  protected getSnapshot(): Partial\u003CTData> {\n    return { ...this.partialData };\n  }\n\n  \u002F**\n   * True on the first render call, false on subsequent updates.\n   * Use to decide between full DOM replacement vs. in-place patch.\n   *\u002F\n  protected get isFirstRender(): boolean {\n    return !this.hasRenderedOnce;\n  }\n\n  \u002F\u002F ── Private helpers ─────────────────────────────────────────────────────\n\n  private buildPendingMessage(): string {\n    const missing = this.getMissingKeys() as string[];\n    if (missing.length === 0) return 'Processing\\u2026';\n    return `Waiting for: ${missing.join(', ')}`;\n  }\n\n  private updateStalenessIndicators(): void {\n    const staleKeys = this.requiredKeys.filter(k => this.isStale(k));\n    const indicator = this.element.querySelector('.panel-stale-indicator');\n    if (staleKeys.length > 0) {\n      const msg = `Stale data: ${(staleKeys as string[]).join(', ')}`;\n      if (indicator) {\n        indicator.textContent = msg;\n      } else {\n        const el = document.createElement('div');\n        el.className = 'panel-stale-indicator';\n        el.textContent = msg;\n        this.header.appendChild(el);\n      }\n    } else {\n      indicator?.remove();\n    }\n  }\n}\n```\n\n---\n\n## Concrete Example: SummaryPanel\n\nCreate `src\u002Fcomponents\u002FSummaryPanel.ts`:\n\n```typescript\nimport { AggregatorPanel } from '.\u002FAggregatorPanel';\nimport { StockQuote } from '..\u002Fservices\u002Fstock-service';\nimport { EmailMessage } from '..\u002Fservices\u002Femail-service';\nimport { CalendarEvent } from '..\u002Fservices\u002Fcalendar-service';\n\ninterface SummaryData {\n  stocks: StockQuote[];\n  emails: EmailMessage[];\n  events: CalendarEvent[];\n}\n\nexport class SummaryPanel extends AggregatorPanel\u003CSummaryData> {\n  constructor() {\n    super({\n      id: 'summary',\n      title: 'Daily Summary',\n      className: 'panel-wide',\n      showCount: true,\n      \u002F\u002F Render as soon as stocks + emails arrive; events are optional bonus\n      requiredKeys: ['stocks', 'emails'],\n      staleThresholdMs: 3 * 60 * 1000,\n    });\n  }\n\n  protected render(data: SummaryData): void {\n    const snapshot = this.getSnapshot();\n\n    const unread  = data.emails.filter(e => !e.read).length;\n    const gainers = data.stocks.filter(q => (q.change ?? 0) > 0).length;\n    const losers  = data.stocks.filter(q => (q.change ?? 0) \u003C 0).length;\n\n    \u002F\u002F Optional key — may not have arrived yet\n    const upcomingCount = snapshot.events\n      ? snapshot.events.filter(ev => new Date(ev.start) > new Date()).length\n      : null;\n\n    const eventsHtml = upcomingCount != null\n      ? `\u003Cdiv class=\"summary-metric\" data-metric=\"events\">\n           \u003Cspan class=\"summary-metric-label\">Upcoming events\u003C\u002Fspan>\n           \u003Cspan class=\"summary-metric-value\">${upcomingCount}\u003C\u002Fspan>\n         \u003C\u002Fdiv>`\n      : '';\n\n    if (this.isFirstRender) {\n      \u002F\u002F Full DOM build on first render\n      this.setContent(`\n        \u003Cdiv class=\"summary-metrics\">\n          \u003Cdiv class=\"summary-metric\" data-metric=\"unread\">\n            \u003Cspan class=\"summary-metric-label\">Unread emails\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value\">${unread}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          \u003Cdiv class=\"summary-metric\" data-metric=\"gainers\">\n            \u003Cspan class=\"summary-metric-label\">Stocks up\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value positive\">${gainers}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          \u003Cdiv class=\"summary-metric\" data-metric=\"losers\">\n            \u003Cspan class=\"summary-metric-label\">Stocks down\u003C\u002Fspan>\n            \u003Cspan class=\"summary-metric-value negative\">${losers}\u003C\u002Fspan>\n          \u003C\u002Fdiv>\n          ${eventsHtml}\n        \u003C\u002Fdiv>\n      `);\n    } else {\n      \u002F\u002F Incremental patch — avoid full DOM thrash on subsequent pushes\n      this.patchMetric('unread', unread);\n      this.patchMetric('gainers', gainers);\n      this.patchMetric('losers', losers);\n      if (upcomingCount != null) this.patchMetric('events', upcomingCount);\n    }\n\n    this.setCount(data.emails.length + data.stocks.length);\n  }\n\n  \u002F** Update a single metric value in-place *\u002F\n  private patchMetric(name: string, value: number): void {\n    const el = this.content.querySelector(\n      `[data-metric=\"${name}\"] .summary-metric-value`\n    );\n    if (el) el.textContent = String(value);\n  }\n}\n```\n\n---\n\n## Coordinator \u002F Push Pattern\n\nCreate `src\u002Fservices\u002Fpanel-coordinator.ts`:\n\n```typescript\nimport { SummaryPanel } from '..\u002Fcomponents\u002FSummaryPanel';\n\n\u002F**\n * Lightweight pub\u002Fsub coordinator. Fetching panels call coordinator.push()\n * after each successful render; aggregator panels receive those updates.\n *\u002F\nexport class PanelCoordinator {\n  private summaryPanel: SummaryPanel;\n\n  constructor(summaryPanel: SummaryPanel) {\n    this.summaryPanel = summaryPanel;\n  }\n\n  push\u003CK extends 'stocks' | 'emails' | 'events'>(\n    key: K,\n    value: unknown\n  ): void {\n    this.summaryPanel.updateData({ [key]: value } as any);\n  }\n}\n```\n\nIn your fetching panels, call `coordinator.push()` after each successful render:\n\n```typescript\n\u002F\u002F Inside StockPanel.fetchData(), after this.render(quotes):\ncoordinator.push('stocks', quotes);\n\n\u002F\u002F Inside EmailPanel.fetchData(), after this.render(messages):\ncoordinator.push('emails', messages);\n```\n\n---\n\n## Key Patterns\n\n1. **Constructor** calls `super()` with `requiredKeys` — the minimum fields needed before the first render.\n2. **updateData(partial)** is the only public ingestion point. It merges, timestamps, and either shows a pending placeholder or triggers `render()`.\n3. **render(data)** receives a fully-typed snapshot; use `this.getSnapshot()` for optional keys.\n4. **isFirstRender** lets you choose between a full DOM replace (first time) vs. incremental in-place patch (subsequent pushes) to avoid unnecessary reflow.\n5. **Staleness indicators** are automatically injected into the header when a key's last-update timestamp exceeds `staleThresholdMs`.\n6. **reset()** clears all state and reverts to pending — call it on session logout or data source disconnect.\n7. Aggregator panels never call `fetch()` or `showLoading()` — they call `showPending()` until required data arrives.\n8. The coordinator is a thin pub\u002Fsub shim; replace with EventEmitter, RxJS Subject, or your app's store if available.\n\n---\n\n## Aggregator vs Fetching Panel Checklist\n\n| Concern | Fetching Panel | Aggregator Panel |\n|---|---|---|\n| Network call | `fetchWithRetry(url)` | none |\n| Initial state | `showLoading()` in constructor | `showPending()` in constructor |\n| Data ingestion | internal async fetch | `updateData(partial)` |\n| First render gate | none | `hasRequiredData()` |\n| Re-render strategy | full replace | incremental patch preferred |\n| Staleness | timer-based refetch | automatic header indicator |\n| `destroy()` | clear interval + super | super only (no timers to clear) |\n\n---\n\n## TypeScript Strict-Mode Notes\n\n- `TData extends Record\u003Cstring, unknown>` ensures key iteration is safe.\n- `Object.keys(partial) as (keyof TData)[]` is safe because `partial` is `Partial\u003CTData>`.\n- The `as TData` cast in `this.render(this.partialData as TData)` is guarded by `hasRequiredData()` — a runtime guarantee backing the compile-time assertion.\n- If your project enables `exactOptionalPropertyTypes`, declare optional aggregated sources as `key?: T | undefined` in `TData`.\n",{"name":5,"description":7},"main","ff671ef61ed6587c49bd54c81cdc751c0b99e363","showcase\u002Fskills\u002Fpanel-component-aggregator","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think about is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add AG064\u002FOpenSpace --skill panel-component-aggregator",{"tool":56,"command":57},"bunx","bunx skills add AG064\u002FOpenSpace --skill panel-component-aggregator",{"tool":59,"command":60},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill panel-component-aggregator","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fpanel-component-aggregator\u002FSKILL.md",true,[64],{"path":65,"resourceType":66,"resourceTypeDesc":67,"sizeBytes":68,"sourceHtmlUrl":69},".skill_id","OTHER","其他",54,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fpanel-component-aggregator\u002F.skill_id",[71,94,110,119,146,161],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":38},"01M6KKMPWA0B5SCCH766F8M5EA","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[78,79,80,81,82,83,25,84,85,86,87,88,89,90,91,92,93],"write special chars ts check","check","write","filters","Existing","type-checking","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":38},"01M6KKMJXVBNVEY3TRK055F4A7","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[101,102,80,90,103,104,91,92,105,106,30,107,108,25,85,109],"readback","write special chars readback","cleanup","read","scripts","verification","post","helper","with",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":38},"01M6KKMEGX9M9NC105J0W3Q5B9","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[80,117,92,25,30,90,118,91,85],"write special chars heredoc","shell",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":130,"publishedAt":38},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[125],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000033","数据分析师","PROFESSION","适用职业",[131,132,133,24,93,134,135,136,137,138,25,139,22,140,141,142,143,144,36,145],"reference","worldmonitor","worldmonitor reference","css","architecture","extracting","hierarchy","source","layer","patterns","edge functions","integrations","open","api","scheduler",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":38},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[153,154,155,156,25,157,109,29,158,159,160],"virtual list","list","virtual","chunk","dom","recycling","implement","performance",{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":38},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[168,169,170,171,172,35,91,173,174,175],"directory","verify","structure","verify directory structure","access","issues","diagnose","file access"]