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

panel-state-persistence

What it does

This skill combines retry logic, saved panel settings and a standard panel layout into one pattern. It is for developers building a web dashboard with several panels that need to be reliable.

When to use it

  • βœ“When you are starting a new dashboard and want all panels to share one reliable structure.
  • βœ“When you want panels that recover from errors and keep their settings between visits.
  • βœ“When you want a single base class that other panels can extend.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-state-persistence/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-state-persistence/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

β€œCan you set up a dashboard where every panel retries on errors and remembers its settings?”

5 new skills a week. 1 minute to read.

How it works

A base panel class provides the layout, retry handling and saved settings. Each new panel extends that class and only adds its own content.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Unified Panel Component Pattern

Create dashboard panel components using vanilla TypeScript (no framework, no JSX). Each panel is a class extending a Panel base class with built-in advanced features.

Architecture Overview

Unified Features

  • Retry Logic: Automatically retries failed data fetches with exponential backoff.
  • State Persistence: Saves panel state (expanded/collapsed, size) to localStorage.
  • Detailed Error Handling: Provides granular error messages and recovery options.
  • Base Panel Structure: Standardized DOM structure with header, content area, and optional count badge.
Panel (base class)
β”œβ”€β”€ element: HTMLElement (outer container, .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)

Base Panel Class

Create 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;
  private retryAttempts = 0;
  private maxRetries = 3;
  private retryDelay = 1000; // starts at 1s, doubles each retry

  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();
    this.loadState();
  }

  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'); }

  protected setFetching(v: boolean): void { this._fetching = v; }
  protected get isFetching(): boolean { return this._fetching; }

  protected async fetchWithRetry(url: string): Promise<any> {
    while (this.retryAttempts < this.maxRetries) {
      try {
        const response = await fetch(url);
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
        return await response.json();
      } catch (error) {
        this.retryAttempts++;
        if (this.retryAttempts >= this.maxRetries) {
          throw new Error(`Failed after ${this.maxRetries} attempts: ${error.message}`);
        }
        await new Promise(
FAQ

Is this different from the retry-only panel pattern?

Yes. This version puts retries, saved settings and the standard layout together in one base class.

Where are the settings kept?

They are kept in the browser's local storage on the same device.

Do I need to know TypeScript?

The examples are in TypeScript, so a developer familiar with it will find this easiest to follow.

Details

Original description by the author

Unified dashboard panel component with robust error handling, retry logic, state persistence, and vanilla TypeScript implementation.

repo: HKUDS/AgentPilot

Popularity

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

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills