panel-base-advanced
Skill này làm gì
Skill này chỉ cho AI agent cách xây dựng một lớp cơ sở panel bảng điều khiển đầy đủ bằng TypeScript thuần. Nó dành cho nhà phát triển muốn panel có tay nắm đổi kích thước, bố cục được lưu, bộ đếm ngược lỗi và dọn dẹp đúng cách.
Khi nào nên dùng
- ✓Khi bạn muốn panel bảng điều khiển ghi nhớ kích thước và bố cục sau khi tải lại trang.
- ✓Khi một panel nên hiển thị bộ đếm ngược lỗi và thử lại với backoff lũy thừa.
- ✓Khi panel cần một bước hủy sạch để xóa bộ hẹn giờ và trình lắng nghe sự kiện.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/legacy/v1/showcase/skills/panel-base-advanced/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Xây dựng một lớp cơ sở panel bảng điều khiển bằng TypeScript, ghi nhớ kích thước, hiển thị bộ đếm ngược thử lại khi có lỗi và dọn dẹp khi bị xóa.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent tạo một lớp Panel có phần đầu, vùng nội dung và hai tay nắm đổi kích thước. Nó lưu bố cục vào localStorage, thử lại các lần lấy dữ liệu thất bại với khoảng chờ tăng dần, hiển thị bộ đếm ngược lỗi và xóa các bộ hẹn giờ trong phương thức destroy.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Resilient Panel — Unified Pattern (v2)
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, via setNewBadge()]
│ │ ├── statusBadge (.panel-data-badge) [optional, via setDataBadge()]
│ │ └── countEl (.panel-count) [optional]
│ ├── content: HTMLElement (.panel-content)
│ ├── resizeHandleRow (.panel-resize-handle-row) [bottom edge]
│ └── resizeHandleCol (.panel-resize-handle-col) [right edge]
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 |
| Error countdown in showError() | Panel base class |
Automatic retry countdown rendered inside the error state UI |
| CircuitBreaker | src/utils/circuit-breaker.ts |
When a service may fail repeatedly; stops hammering the API and serves stale cache instead |
| localStorage persistence | Panel.saveMap() / loadMap() |
When you want grid-span (not pixel 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
Authoritative implementation. Use this verbatim; do not revert to the older
saveState()/loadState()width/height approach.
export interface PanelOptions {
id: string;
title: string;
showCount?: boolean;
className?: string;
}
export class Panel {
protected element: HTMLElement;
protected content: HTMLElement;
protected header: HTMLElement;
protected headerLeft: HTMLElement;
protected countEl: HTMLElement | null = null;
protected statusBadge: HTMLElement | null = null;
protected newBadge: HTMLElement | null = null;
protected panelId: string;
private _fetching = false;
private _countdownInterval: ReturnType<typeof setInterval> | null = null;
private _resizeListeners: Array<{ target: EventTarget; type: string; fn: EventListenerOrEventListenerObject }> = [];
// 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 ? ' ' + options.className : ''}`;
this.element.dataset.panel = options.id;
// Header
this.header = document.createElement('div');
this.header.className = 'panel-header';
this.headerLeft = document.createElement('div');
this.headerLeft.className = 'panel-header-left';
const title = document.createElement('span');
title.className = 'panel-title';
title.textContent = options.title;
this.headerLeft.appendChild(title);
this.header.appendChild(this.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`;
// Dual resize handles
const resizeHandleRow = document.createElement('div');
resizeHandleRow.className = 'panel-resize-handle-row';
const resizeHandleCol = document.createElement('div');
resizeHandleCol.className = 'panel-resize-handle-col';
this.element.appendChild(this.header);
this.element.appendChild(this.content);
this.element.appendChild(resizeHandleRow);
this.element.appendChild(resizeHandleCol);
this._initResizeHandles(resizeHandleRow, resizeHandleCol);
this.sh
Câu hỏi thường gặp
Phương thức destroy làm gì?
Skill nói nó dọn dẹp bộ hẹn giờ và trình xử lý sự kiện, để các panel đã bị xóa không tiếp tục chạy.
Thử lại hoạt động thế nào?
Skill dùng backoff lũy thừa, nên mỗi lần thử lại chờ lâu hơn lần trước.
Bố cục được lưu ở đâu?
Skill lưu trạng thái bố cục vào localStorage, giữ được giữa các lần tải trang trong trình duyệt đó.
Chi tiết
Mô tả gốc của tác giả
Unified guide for authoring dashboard panel components in vanilla TypeScript — covers the authoritative Panel base class (grid-span persistence, dual resize handles, radar loading animation, exponential-backoff error countdown, data/new badge helpers, full destroy() cleanup), localStorage state via loadMap/saveMap, 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
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #13062
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.