Skip to content

Add Tasks panel infrastructure with type-safe IPC protocol#772

Open
EhabY wants to merge 5 commits intomainfrom
tasks/infrastructure
Open

Add Tasks panel infrastructure with type-safe IPC protocol#772
EhabY wants to merge 5 commits intomainfrom
tasks/infrastructure

Conversation

@EhabY
Copy link
Collaborator

@EhabY EhabY commented Feb 4, 2026

Summary

Adds foundational infrastructure for the Tasks panel: a type-safe IPC protocol for webview-extension communication, the TasksPanel backend, and comprehensive test coverage.

Type-Safe IPC Protocol

The protocol uses phantom types (inspired by tRPC) to carry type information at compile time without runtime overhead:

// Define API with types
const getTask = defineRequest<{ taskId: string }, Task>("getTask");

// Extension: handler params and return type are inferred
requestHandler(TasksApi.getTask, (p) => this.client.getTask("me", p.taskId))

// Webview: params and response are type-checked
const task = await ipc.request(TasksApi.getTask, { taskId: "123" }); // → Task

Three message types with distinct semantics:

Type Direction Response Use Case
Request webview → extension Yes Data fetching, mutations
Command webview → extension No Fire-and-forget actions (open URL, download)
Notification extension → webview No Push updates (task changed, logs appended)

Why this design:

  • Phantom types provide full type safety with zero runtime cost
  • Separating requests/commands/notifications makes the communication pattern explicit
  • Handler wrappers (requestHandler, commandHandler) ensure type safety at definition time, catching errors before they reach call sites
  • Single TasksApi object serves as the source of truth for all messages

Package Structure

packages/
├── shared/           # Types and API definitions (used by extension + webviews)
├── webview-shared/   # React hooks (useIpc) for webview communication
└── tasks/            # Tasks panel React app

Shared types live in @repo/shared so both the extension (Node.js) and webviews (browser) import the same definitions.

TasksPanel Backend

  • CRUD operations - Create, delete, pause, resume tasks
  • Template management - Fetch templates and presets with 5-minute TTL cache
  • Log fetching - Cached for completed/errored/paused tasks (stable states)
  • Push notifications - Real-time updates via tasksUpdated notification

Closes #775

@EhabY EhabY force-pushed the tasks/infrastructure branch 2 times, most recently from 318c084 to 33757b5 Compare February 4, 2026 07:49
@EhabY EhabY self-assigned this Feb 4, 2026
Adds foundational infrastructure for the Tasks panel:

Backend (TasksPanel.ts):
- CRUD operations for tasks (create, delete, pause, resume)
- Template and preset management
- Log fetching with caching
- Real-time push notifications to webview

Type-safe IPC Protocol:
- Generic request/response/notification patterns
- Compile-time type safety for webview-extension messages
- useIpc hook for React components
- useTasksApi hook with typed methods

Supporting infrastructure:
- Test setup for jsdom compatibility with Lit elements
- Codicon stylesheet integration for vscode-elements
- React Compiler integration with ESLint plugin
- pnpm catalog for consistent dependency versions
@EhabY EhabY force-pushed the tasks/infrastructure branch 2 times, most recently from 19abe9f to 8c9d478 Compare February 4, 2026 16:31
@EhabY EhabY force-pushed the tasks/infrastructure branch from 8c9d478 to 4fdc74e Compare February 4, 2026 19:15
@EhabY EhabY force-pushed the tasks/infrastructure branch 3 times, most recently from 068ac5e to 343940c Compare February 5, 2026 09:15
- Remove unused `scope` feature from IPC protocol (YAGNI)
- Remove redundant array spreads in TasksPanel
- Make TaskDetails extend TaskActions to reduce duplication
- Remove handler fallback in TasksPanel (keep requests/commands separate)
- Add notification subscription support to useIpc hook
- Add tests for onNotification feature
- Remove redundant individual exports from tasks/api.ts (export as group only)
Copy link
Collaborator

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor nits for now. Still haven't had time to read and digest it all

@EhabY EhabY force-pushed the tasks/infrastructure branch from 6b927b2 to c951db0 Compare February 5, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Tasks panel infrastructure with type-safe IPC protocol

2 participants