본문으로 건너뛰기
cccskills
무료GitHub에 공개

admin-debug-context

Admin debug system wiring for the floating AdminIndicator's live debug data and Copy Full Context. Use when adding debug visibility to a route or feature, wiring useDebugContext or the debug panel, capturing console errors, or enabling the copy-context workflow for a page.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md7.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Admin Debug Context

Performance guarantee

The entire debug system is zero cost for non-admins:

  • AdminIndicatorWrapper checks selectIsAdmin from Redux and returns null immediately if false
  • Both AdminIndicatorIsland (ssr layout) and DynamicAdminIndicatorWrapper (authenticated layout) use dynamic(..., { ssr: false }) — the admin bundle never downloads for non-admins
  • useDebugContext is a no-op when isAdmin is false — no dispatch, no effect, no render cost

Architecture — four layers

Layout (server)
  └── AdminIndicatorWrapper (client, admin-only)
        ├── AdminDebugContextCollector   ← auto: pathname, searchParams, viewport,
        │                                        console errors, unhandledrejection
        └── AdminIndicator (Small/Medium/Large)
              ├── MediumIndicator
              │     └── debugModules icons → DebugModulePanel modal
              └── LargeIndicator
                    ├── API config + health grid
                    ├── Recent API calls log
                    ├── [Copy Full Context] button ← assembles everything for AI agent
                    ├── Console Errors panel        ← captured automatically
                    └── Debug Data (JSON)           ← written via useDebugContext

What is auto-captured (no route work needed)

AdminDebugContextCollector runs at layout level inside AdminIndicatorWrapper. For every admin session it automatically captures:

DataHow
Current pathnameusePathname() on every navigation
Search paramsuseSearchParams() on every navigation
Browser viewportwindow.innerWidth/Height
User agentnavigator.userAgent
Navigation countincrements on each pathname change
console.error callspatches console.error while mounted
unhandledrejection eventswindow.addEventListener
window.error eventswindow.addEventListener

This is available instantly in the "Copy Full Context" snapshot even for routes that add zero custom debug code.


Adding route/feature debug data

The hook — use this everywhere

import { useDebugContext } from '@/hooks/useDebugContext';

export default function MyComponent({ sessionId }: { sessionId: string }) {
    const session = useAppSelector(s => selectSession(s, sessionId));
    const { publish, isActive } = useDebugContext('Chat');  // namespace

    useEffect(() => {
        publish({
            'Session ID': sessionId,
            'Status': session?.status,
            'Message Count': session?.messages.length,
            'Conversation ID': session?.conversationId,
        });
    }, [isActive, session?.status, session?.messages.length, sessionId]);
}

Key rules:

  • First arg is the namespace — appears as group header in the debug panel
  • Keys are auto-prefixed: "Chat:Session ID", "Chat:Status", etc.
  • isActive is true only when isAdmin && isDebugMode — use it in useEffect deps to gate expensive collection
  • The hook auto-clears all namespace keys on unmount — no manual cleanup needed
  • Safe in any component tree — pure no-op for non-admins

Hook API

const { publish, publishKey, isActive } = useDebugContext('Namespace');

publish({ 'Key': value, 'Other Key': otherValue });  // merge namespaced data
publishKey('Key', value);                             // set single key
isActive  // boolean — true only when admin AND debug mode is on

Adding a debug module panel

For richer feature-specific UIs (not just JSON data), create a debug module:

Step 1 — Create the component

// components/admin/debug/MyFeatureDebug.tsx
'use client';
import { useAppSelector } from '@/lib/redux/hooks';

export default function MyFeatureDebug() {
    // Read exclusively from Redux selectors — no local fetch, no useState for data
    const data = useAppSelector(selectSomething);
    return <div className="p-4 type-secondary font-mono">{JSON.stringify(data, null, 2)}</div>;
}

Step 2 — Register in the registry

// components/admin/debug/debugModuleRegistry.tsx
import MyFeatureDebug from './MyFeatureDebug';
import { Zap } from 'lucide-react';

export const debugModules: DebugModule[] = [
    // ... existing modules ...
    {
        id: 'my-feature',
        name: 'My Feature',
        icon: Zap,
        component: MyFeatureDebug,
        description: 'Live state of my feature',
        color: 'text-purple-400',
    },
];

The icon appears in the MediumIndicator debug row. Clicking opens the panel modal. Component only mounts when the panel is open — zero overhead when closed.


Copy Full Context — the AI agent workflow

The Copy button in LargeIndicator assembles a complete markdown snapshot:

# Admin Debug Context Snapshot
Generated: 2026-03-27T10:42:00.000Z
Admin: admin@example.com

## Route
- **Path:** /demos/chat/c/abc-123
- **Viewport:** 1440×900
- **Render Count:** 3

## API Config
- **Active Server:** localhost
- **Backend URL:** http://localhost:8000
- **Health:** healthy (42ms)

## Feature Debug Data
### Chat
- **Session ID:** sess-xyz
- **Status:** streaming
- **Message Count:** 7

## Recent API Calls
| Status | Method | Path | HTTP | Duration |
...

## Console Errors
No errors captured.

Workflow: Admin sees a bug → opens LargeIndicator → clicks Copy → pastes into AI agent chat. Agent gets full context: what page, what state, what the API is doing, any errors.


Data sources reference

WhatSelectorSlice
Is adminselectIsAdminuserSlice
Debug mode onselectIsDebugModeadminDebugSlice
Route contextselectRouteContextadminDebugSlice
Console errorsselectConsoleErrorsadminDebugSlice
Debug data (JSON)selectDebugDataadminDebugSlice
Active serverselectActiveServerapiConfigSlice
Backend URLselectResolvedBaseUrlapiConfigSlice
Server healthselectActiveServerHealthapiConfigSlice
Recent API callsselectRecentApiCallsapiConfigSlice
Active chat sessionselectActiveChatSessionIdactiveChatSlice
Chat session objectselectSession(state, sessionId)chatConversations
Chat messagesselectMessages(state, sessionId)chatConversations

Viewing debug context

  1. Small indicator — two colored dots (server env, health)
  2. Medium indicator — debug icon row; click any icon for that feature's panel
  3. Large indicator — full admin dashboard:
    • Copy button (always visible) — one click to copy everything for an AI agent
    • Console Errors panel — auto-captured, collapsible, shows stack traces
    • Debug Data section (debug mode on) — namespaced JSON from useDebugContext
    • API calls log and all environments health grid

Enable debug mode: click the Debug toggle in MediumIndicator or LargeIndicator.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Compact two-icon Copy / Copy-for-AI controls (components/agent-copy). Use when adding copy buttons to a row, card, list, or record; merging duplicate Copy/JSON/AI controls; continuing the copy rollout; or writing a Copy-for-AI payload. NOT for markdown content actions (use rich-document-actions).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

Disclosing a surface's existing fixed AI jobs in the shell's top Agents menu. Use when a page, panel, overlay, or window already runs a mandate behind a button, assist, automatic action, or mode; when the agent-disclosure guard names a file; or during a surface check.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

The watch-fix-rerun method for making an existing platform agent or automated process efficient and correct: baseline its ledger, run one unit yourself, fix the class behind every wasted call, rerun, record. Use when asked to improve, optimize, watch, or 'make efficient' an agent, a sandbox session, a sync job, or any recurring automated process.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

Redux state for agent execution and firing agent shortcuts. Use when editing features/agents/redux/, building agent UI, creating a conversation, touching assembleRequest or NDJSON stream state, wiring agent-state selectors, adding a per-conversation capability, or triggering a shortcut from a button, menu, or code (useShortcutTrigger, launchAgentExecution).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

The provision for a call site: the exhaustive menu of values that place in the code can realistically produce. Use before creating or fixing a mandate or agent that reasons about more than its own input, when deciding whether an agent can answer at all with what it is sent, or when its output 'looks right' but nobody checked it could be. NOT for building the agent (use create-agent).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

The agent.review_queue register for work Arman must see or test in the UI. Use at the end of any task that produced something reviewable, at the start of a task to check prior feedback, and when reviewing, claiming, routing, or repairing a queue row.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

armanisadeghi/ai-matrx32026년 10월 19일 업데이트

armanisadeghi의 스킬 모두 보기

이 스킬의 문제 신고