[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXA4T8RHJN1S8SW33X30FY":3,"skill-same:01M6HXA4T8RHJN1S8SW33X30FY":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":45,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":48,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M6HXA4T8RHJN1S8SW33X30FY","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.","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fpanel-component-aggregator\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"component","panel component aggregator","panel","aggregator","first","summary","synthesize","pattern","data","panels","via","metrics","rendering","render","re","updates","for","dashboard","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","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fpanel-component-aggregator",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add HKUDS\u002FAgentPilot --skill panel-component-aggregator",{"tool":56,"command":57},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill panel-component-aggregator",{"tool":59,"command":60},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill panel-component-aggregator","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fexamples\u002Fmy-daily-monitor\u002Fskills\u002Fpanel-component-aggregator\u002F.skill_id",[71,91,110,135,158,181],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":37},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[73,78,79,80,81,82,83,84,85,86,87,88,89,90],"prepare","requests","with","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":37},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[93,98,99,100,101,102,103,104,105,106,107,108,109],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":121,"publishedAt":37},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[116],{"categoryNo":117,"categoryName":118,"taxonomyType":119,"taxonomyTypeDesc":120},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[122,123,124,101,125,126,127,128,129,130,131,132,133,134],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":142,"publishedAt":37},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[141],{"categoryNo":117,"categoryName":118,"taxonomyType":119,"taxonomyTypeDesc":120},[143,144,145,101,146,147,148,149,150,124,100,85,151,152,153,35,154,155,156,157],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":159,"name":160,"nameZh":6,"description":161,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":162,"categories":163,"keywords":164,"publishedAt":37},"01M6HYAM9FSGV6E52AYENDQXYH","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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[165,166,167,168,169,170,171,172,173,174,175,176,177,178,35,179,180],"write special chars ts check","write","check","type","files","filters","only","template","file","python","typescript","output","Existing","type-checking","errors","script",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":187,"publishedAt":37},"01M6HYAH05HGV7SVWSVR8PJRQD","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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[188,189,166,80,35,180,190,191,29,192,193,172,173,194,195,174],"write special chars readback","readback","helper","post","scripts","read","verification","cleanup"]