Agent Skillslichtblick-suite/lichtblick › panel-extension-api

panel-extension-api

GitHub

提供面板扩展基础设施知识,涵盖PanelExtensionAdapter、增量渲染状态构建、上下文API、背压机制及面板生命周期管理。

.github/skills/panel-extension-api/SKILL.md lichtblick-suite/lichtblick

Trigger Scenarios

询问面板扩展架构 查询RenderState增量构建逻辑 了解PanelExtensionContext API用法 排查pauseFrame背压问题 咨询面板生命周期钩子

Install

npx skills add lichtblick-suite/lichtblick --skill panel-extension-api -g -y
More Options

Non-standard path

npx skills add https://github.com/lichtblick-suite/lichtblick/tree/develop/.github/skills/panel-extension-api -g -y

Use without installing

npx skills use lichtblick-suite/lichtblick@panel-extension-api

指定 Agent (Claude Code)

npx skills add lichtblick-suite/lichtblick --skill panel-extension-api -a claude-code -g -y

安装 repo 全部 skill

npx skills add lichtblick-suite/lichtblick --all -g -y

预览 repo 内 skill

npx skills add lichtblick-suite/lichtblick --list

SKILL.md

Frontmatter
{
    "name": "panel-extension-api",
    "description": "Deep panel infrastructure knowledge: PanelExtensionAdapter, RenderState incremental building, PanelExtensionContext API, pauseFrame backpressure, panel lifecycle, and the PanelAPI internal hooks."
}

Panel Extension API Skill

The panel infrastructure connects panels to the MessagePipeline and manages their lifecycle.

Architecture

MessagePipeline (zustand store)
    │
    ▼
PanelExtensionAdapter (per-panel bridge)
    │   ├── buildRenderState()  (incremental state building)
    │   ├── pauseFrame()        (backpressure mechanism)
    │   └── PanelExtensionContext (API exposed to panel code)
    ▼
Panel Component (renders data)

Core Files

File Role
packages/suite-base/src/components/PanelExtensionAdapter/PanelExtensionAdapter.tsx React component, manages panel lifecycle + subscriptions
packages/suite-base/src/components/PanelExtensionAdapter/renderState.ts Incrementally builds RenderState from pipeline state
packages/suite-base/src/context/PanelExtensionContext.ts Context type panels consume
packages/suite-base/src/PanelAPI/ Internal hooks for built-in panels

RenderState (Incremental Building)

interface RenderState {
  topics?: readonly Topic[];
  currentFrame?: readonly MessageEvent[];
  allFrames?: readonly MessageEvent[];  // preloaded range
  currentTime?: Time;
  parameters?: Map<string, unknown>;
  variables?: Map<string, unknown>;
  colorScheme?: "dark" | "light";
  appSettings?: Map<string, unknown>;
}
  • renderState.ts tracks which fields changed since the last render
  • Only changed fields are rebuilt (e.g. if only currentTime changed, topics is reused)
  • Reference equality on unchanged fields enables React memo optimizations in panels

PanelExtensionContext (Core API Introduction)

interface PanelExtensionContext {
  subscribe(topics: SubscriptionConfig[]): void;
  onRender(renderState: RenderState, done: () => void): void;
  saveState(state: unknown): void;
  seekPlayback(time: Time): void;
  setParameter(key: string, value: unknown): void;
}

This snippet is a core API introduction, not the full type surface. For the complete PanelExtensionContext definition (including read-only properties, watch/subscription APIs, publish/service methods, settings APIs, and range subscriptions), see: packages/suite/src/index.ts.

The render callback is onRender(renderState, done). The panel must call done() when it has finished processing the frame — this drives pauseFrame backpressure.

pauseFrame (Backpressure)

const done = pauseFrame(panelId);
// ... expensive rendering (GPU upload, chart update) ...
done(); // ready for next frame
  • Prevents the pipeline from pushing new data while a panel is still rendering
  • Critical for the 3D panel (GPU upload) and Plot panel (chart update)
  • If a panel doesn't call done() within the timeout, the next frame is forced

Panel Lifecycle

  1. Mount — adapter creates the context, panel initPanel() is called
  2. Subscribe — panel declares topics via context.subscribe()
  3. Render loop — pipeline pushes a new RenderStateonRender() fires
  4. Config change — user edits settings → panel re-renders with new config
  5. Unmount — adapter unsubscribes, panel cleanup() is called

Creating a New Panel

panels/MyPanel/
├── index.tsx       # registration + entry point
├── MyPanel.tsx     # main component
├── settings.ts     # settings tree definition
├── types.ts        # panel-specific types
└── MyPanel.test.tsx

PanelAPI (Internal Hooks)

Built-in panels access data via React hooks in PanelAPI instead of the PanelExtensionContext render-callback model:

import * as PanelAPI from "@lichtblick/suite-base/PanelAPI";
  • useDataSourceInfo() — rarely-changing metadata (topics, datatypes, capabilities, startTime); re-renders only when metadata changes, not during playback.

Performance Notes

  • Incremental RenderState minimizes object creation — only changed fields are rebuilt
  • pauseFrame prevents data flooding slow panels
  • Subscription scoping delivers only subscribed topics to each panel
  • Profile (React DevTools Profiler / Chrome Performance) before adding memoization

Skills Reference

  • For the upstream data bus: load message-pipeline skill

Version History

  • cab9317 Current 2026-07-24 12:17

Same Skill Collection

.github/skills/3d-rendering/SKILL.md
.github/skills/caching-internals/SKILL.md
.github/skills/deserialization/SKILL.md
.github/skills/e2e-playwright-mcp/SKILL.md
.github/skills/electron-internals/SKILL.md
.github/skills/extensions-internals/SKILL.md
.github/skills/layouts-internals/SKILL.md
.github/skills/mcap-format/SKILL.md
.github/skills/message-path/SKILL.md
.github/skills/message-pipeline/SKILL.md
.github/skills/panel-image/SKILL.md
.github/skills/panel-log/SKILL.md
.github/skills/panel-map/SKILL.md
.github/skills/panel-raw-messages/SKILL.md
.github/skills/panel-state-transitions/SKILL.md
.github/skills/panel-user-scripts/SKILL.md
.github/skills/performance/SKILL.md
.github/skills/player-internals/SKILL.md
.github/skills/plot-internals/SKILL.md
.github/skills/remote-caching/SKILL.md
.github/skills/test-conventions/SKILL.md
.github/skills/theme/SKILL.md
.github/skills/unit-testing/SKILL.md
.github/skills/web-workers/SKILL.md
.github/skills/websocket-connection/SKILL.md

Metadata

Files
0
Version
cab9317
Hash
e8f181ea
Indexed
2026-07-24 12:17

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 11:27
浙ICP备14020137号-1 $Carte des visiteurs$