Skip to content

feat(vscode-ail-chat): toggle side panel — run history + pipeline steps trees [Unit 4] #167

@AlexChesser

Description

@AlexChesser

Part of #162. Depends on #163 (vscode stub). Can be worked in parallel with #164/#165.

Problem

There is no way to inspect past runs or browse the active pipeline's steps without opening the YAML file manually. The user has no audit trail and no step-navigation shortcut.

Solution

Two new tree views in the ail-chat-sidebar container, hidden by default behind a toggle button in the chat view's title bar.

Toggle mechanism

let panelVisible = false;
commands.registerCommand('ail-chat.toggleInfoPanel', () => {
  panelVisible = !panelVisible;
  void commands.executeCommand('setContext', 'ail-chat.panelVisible', panelVisible);
});

Views use "when": "ail-chat.panelVisible" in package.json so they appear/disappear without disposal.

Run History tree (ail-chat.historyView)

  • RunHistoryProvider stores { runId, prompt, timestamp, logPath } in workspaceState
  • logPath is computed at record time: ~/.ail/projects/<sha1(cwd)>/runs/<runId>.jsonl — not at click time, so workspace changes don't lose history
  • Capped at 100 entries (evict oldest on overflow)
  • addRun(runId, prompt, cwd) called by ChatViewProvider on each run_started event
  • Tree item: first 60 chars of prompt + relative timestamp

ail-chat.openRunLog command:

  1. Read logPath from the RunItem
  2. Parse NDJSON, format as readable text (step IDs, responses, costs, errors)
  3. vscode.workspace.openTextDocument({ content, language: 'log' }) + showTextDocumentno webview message; native document gives find/copy/folding for free

Pipeline Steps tree (ail-chat.stepsView)

  • PipelineStepsProvider reads the active pipeline YAML via the yaml package (already a dep)
  • Top-level steps only — sub-pipeline references (pipeline: ./workflows/foo.ail.yaml) render as a single node labelled with the filename; no recursion
  • Error node (no expand) when pipeline is missing, YAML is malformed, or in passthrough mode
  • Each item: step id + type icon (prompt/context/skill/sub-pipeline)

ail-chat.openStep command:

  1. vscode.window.showTextDocument(vscode.Uri.file(pipelinePath))
  2. Search for the step id: line → editor.revealRange(..., InCenter)

Files

New:

  • vscode-ail-chat/src/history-tree-provider.ts
  • vscode-ail-chat/src/steps-tree-provider.ts
  • vscode-ail-chat/test/history-tree-provider.test.ts
  • vscode-ail-chat/test/steps-tree-provider.test.ts

Modified:

  • vscode-ail-chat/src/extension.ts — register both providers + toggle command
  • vscode-ail-chat/src/chat-view-provider.ts — call historyProvider.addRun(...) on run_started; call stepsProvider.refresh(pipeline) on pipeline change
  • vscode-ail-chat/package.json:
    • New views with when: ail-chat.panelVisible
    • ail-chat.toggleInfoPanel command + $(layout-sidebar-right) icon
    • menus.view/title entry for the toggle button
    • ail-chat.openRunLog and ail-chat.openStep commands

Reference implementations: vscode-ail/src/views/HistoryTreeProvider.ts (152 lines) and vscode-ail/src/views/StepsTreeProvider.ts (185 lines) — match tree-item shape and contextValue conventions, but adapt to the chat extension's state model.

Test coverage (requires vscode stub from #163)

history-tree-provider.test.ts:

  • addRun stores entry with correct logPath computed from cwd
  • 101st entry evicts the oldest
  • workspaceState round-trip (mock the context)
  • getChildren returns entries reverse-chronological

steps-tree-provider.test.ts:

  • Valid multi-step pipeline → one StepItem per top-level step
  • Sub-pipeline reference → single node with filename label
  • Malformed YAML → error node, no throw
  • Null pipeline (passthrough) → empty tree

Verification

  1. Toggle button in chat view title → "Run History" and "Pipeline Steps" appear; click again → disappear
  2. Run two prompts → both appear in history; click one → VS Code opens the run log as a log-language document
  3. Open a multi-step pipeline → steps tree shows top-level steps; click a step → YAML opens at that id: line, revealed in viewport
  4. npm test passes

Risk

Low. Tree views are hidden by default; toggle is fully opt-in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions