Skip to content
Skillpedia
Websites & UI (frontend)7.8k Β· #13063

panel-breaker-backoff

What it does

This skill guides the AI agent to build resilient dashboard panels. It is for developers whose panels call APIs that sometimes fail or get rate limited.

When to use it

  • βœ“When a panel's API calls fail from time to time and need retries.
  • βœ“When a service may fail repeatedly and should stop being called for a while.
  • βœ“When you want to wrap an existing fetch call with a circuit breaker.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-breaker-backoff/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-breaker-backoff/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œMake my dashboard panel retry failed API calls and stop calling the service for a while if it keeps failing.”

5 new skills a week. 1 minute to read.

How it works

The agent builds a Panel base class with retry logic that backs off between attempts. It wraps the service call with a circuit breaker, so repeated failures trigger a cooldown and stored data is shown instead.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Resilient Panel β€” Unified Pattern

Create dashboard panel components using vanilla TypeScript (no framework, no JSX). Each panel is a class extending a Panel base class and optionally wraps its data source with a CircuitBreaker.


Architecture Overview

Panel (base class)
β”œβ”€β”€ element: HTMLElement (.panel)
β”‚   β”œβ”€β”€ header: HTMLElement (.panel-header)
β”‚   β”‚   β”œβ”€β”€ headerLeft (.panel-header-left)
β”‚   β”‚   β”‚   β”œβ”€β”€ title (.panel-title)
β”‚   β”‚   β”‚   └── newBadge (.panel-new-badge) [optional]
β”‚   β”‚   β”œβ”€β”€ statusBadge (.panel-data-badge) [optional]
β”‚   β”‚   └── countEl (.panel-count) [optional]
β”‚   β”œβ”€β”€ content: HTMLElement (.panel-content)
β”‚   └── resizeHandle (.panel-resize-handle)

Resilience layers (choose what you need)

Layer File When to use
isFetching guard Panel base class Always β€” prevents concurrent duplicate requests
Exponential-backoff retry Panel.fetchWithRetry() When you own the fetch call and want per-request retry before surfacing an error
CircuitBreaker src/utils/circuit-breaker.ts When a service may fail repeatedly; stops hammering the API and serves stale cache instead
localStorage persistence Panel.saveState() / loadState() When you want collapsed/size state to survive page reloads

Wrapping an existing service call with CircuitBreaker is a one-liner:

// Before
const data = await fetchStockQuotes();
// After β€” adds caching + cooldown with zero refactor
const data = await breaker.execute(() => fetchStockQuotes(), []);

File 1 β€” src/components/Panel.ts

export interface PanelOptions {
  id: string;
  title: string;
  showCount?: boolean;
  className?: string;
}

export class Panel {
  protected element: HTMLElement;
  protected content: HTMLElement;
  protected header: HTMLElement;
  protected countEl: HTMLElement | null = null;
  protected panelId: string;
  private _fetching = false;

  // Retry state (used by fetchWithRetry)
  protected retryAttempts = 0;
  protected retryDelay = 1000; // ms; doubles each attempt
  private maxRetries = 3;

  constructor(options: PanelOptions) {
    this.panelId = options.id;
    this.element = document.createElement('div');
    this.element.className = `panel ${options.className ?? ''}`;
    this.element.dataset.panel = options.id;

    // Header
    this.header = document.createElement('div');
    this.header.className = 'panel-header';

    const headerLeft = document.createElement('div');
    headerLeft.className = 'panel-header-left';

    const title = document.createElement('span');
    title.className = 'panel-title';
    title.textContent = options.title;
    headerLeft.appendChild(title);
    this.header.appendChild(headerLeft);

    // Count badge (optional)
    if (options.showCount) {
      this.countEl = document.createElement('span');
      this.countEl.className = 'panel-count';
      this.countEl.textContent = '0';
      this.header.appendChild(this.countEl);
    }

    // Content area
    this.content = document.createElement('div');
    this.content.className = 'panel-content';
    this.content.id = `${options.id}Content`;

    this.element.appendChild(this.header);
    this.element.appendChild(this.content);
    this.showLoading();
  }

  // ── Public API ───────────────────────────────────────────────────────

  public getElement(): HTMLElement { return this.element; }

  public showLoading(message = 'Loading...'): void {
    this.content.innerHTML = `
      <div class="panel-loading">
        <div class="panel-loading-spinner"></div>
        <div class="panel-loading-text">${message}</div>
      </div>`;
  }

  public showError(message = 'Failed to load', onRetry?: () => void): void {
    this.content.innerHTML = `
      <div class="panel-error-state">
        <div class="panel-error-msg">${message}</div>
        ${onRetry ? '<button class="panel-retry-btn" data-panel-retry>Retry</button>' : ''}
      </div>`;
    if (onRetry) {
      this.content.querySelector('[data-panel-retry]')
        ?.addEventListener('click', onRetry);
    }
  }

  public setContent(html: string): void { this.content.innerHTML = html; }

  public setCount(count: number): void {
    if (this.countEl) this.countEl.textContent = count.toString();
  }

  public show(): void { this.element.classList.remove('hidden'); }
  public hide(): void { this.element.classList.add('hidden'); }

  public destroy(): void { this.eleme
FAQ

What is the one-liner the skill mentions?

It is wrapping an existing service call with the breaker's execute method, which adds protection without a rewrite.

When should I skip the retry layer?

The skill says retries suit calls you own, while the breaker suits services that fail repeatedly.

Does state survive reloads?

The skill uses save and load state methods so collapsed or sized panels remain that way after a reload.

Details

Original description by the author

Unified guide for authoring dashboard panel components in vanilla TypeScript β€” covers the Panel base class architecture, localStorage state persistence, exponential-backoff retry, and CircuitBreaker integration. Shows how to wrap any existing fetchX() service call with CircuitBreaker.execute() as a one-liner and clarifies when each resilience layer is appropriate.

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#13063
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills