Skip to content

Add Windows support for claude-canvas#8

Open
zepef wants to merge 21 commits intodvdsgl:mainfrom
zepef:main
Open

Add Windows support for claude-canvas#8
zepef wants to merge 21 commits intodvdsgl:mainfrom
zepef:main

Conversation

@zepef
Copy link

@zepef zepef commented Jan 12, 2026

Summary

This PR adds full Windows support for claude-canvas, enabling the TUI toolkit to work on Windows with Windows Terminal. Also includes a new calendar CRUD feature with local JSON storage.

Windows Support Changes

  • Cross-platform IPC: TCP sockets on Windows, Unix sockets on Unix/macOS
  • Windows Terminal support: Split panes (wt.exe sp) and new tabs (wt.exe new-tab)
  • Launcher scripts: Uses .cmd scripts to avoid shell escaping issues
  • New CLI option: --config-file for both show and spawn commands
  • Wrapper scripts: Added run-canvas.cmd and run-canvas.ps1 for Windows
  • Terminal detection: Recognizes Windows Terminal via WT_SESSION env var
  • IPC discovery: Stores TCP ports in temp files for Windows IPC

Calendar CRUD Feature (New)

  • Edit scenario: Full create/read/update/delete operations for calendar events
  • Local storage: Events persist to ~/.claude/calendar-events.json
  • Modal UI: Dialog components for creating and editing events
  • Keyboard shortcuts: c create, e edit, d delete, arrow keys navigate

Files Modified

File Changes
ipc/types.ts Cross-platform helpers, TCP port file management
ipc/server.ts Dual-mode server (Unix sockets / TCP)
ipc/client.ts Dual-mode client with port file reading
terminal.ts Windows Terminal spawning with launcher scripts
cli.ts Added --config-file, cross-platform IPC helpers
canvas-api.ts Fixed async server creation
run-canvas.cmd New Windows batch wrapper
run-canvas.ps1 New PowerShell wrapper
calendar/components/* Modal UI components (6 new files)
calendar/hooks/use-storage.ts React hook for CRUD operations
calendar/utils/event-storage.ts JSON file persistence
calendar/scenarios/edit-view.tsx CRUD-enabled calendar view
scenarios/calendar/edit.ts Edit scenario definition

Testing

Tested on Windows 11 with Windows Terminal:

  • bun run src/cli.ts env detects Windows environment
  • bun run src/cli.ts spawn calendar opens in new WT tab
  • ✅ Calendar renders with events using --config-file
  • ✅ Calendar CRUD: create, edit, delete events with persistence
  • ✅ Launcher scripts generated in %TEMP% for debugging

Backwards Compatibility

All existing Unix/macOS functionality preserved - changes only activate on Windows (process.platform === "win32").

🤖 Generated with Claude Code

zepef and others added 7 commits January 12, 2026 05:11
- Add cross-platform IPC: TCP sockets on Windows, Unix sockets on Unix/macOS
- Add Windows Terminal support: split panes (wt.exe sp) and new tabs
- Use launcher scripts (.cmd) to avoid shell escaping issues
- Add --config-file option for both show and spawn commands
- Add run-canvas.cmd and run-canvas.ps1 wrapper scripts
- Update terminal detection to recognize Windows Terminal (WT_SESSION)
- Store TCP ports in temp files for Windows IPC discovery

Tested on Windows with Windows Terminal - calendar canvas spawns
correctly in new tabs with events displayed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- test-calendar.json: January 2026 calendar with sample events
- test-document.json: README markdown document
- test-flight.json: JFK to LAX flight search with correct Flight schema

These files demonstrate proper config format for each canvas type
and were used to validate the Windows port.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Platform-specific requirements (tmux for Unix, Windows Terminal for Windows)
- Bun installation command for Windows
- Windows Terminal installation options
- Manual testing commands
- Technical notes on how Windows support works (TCP sockets, wt.exe, launcher scripts)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add edit scenario with full create/read/update/delete operations
- Persist events to ~/.claude/calendar-events.json
- Add modal dialog UI components for event editing
- Fix Date object serialization/deserialization for proper display
- Add keyboard shortcuts: c=create, e=edit, d=delete

New files:
- Modal components (overlay, text-input, time-picker, color-picker)
- Event modal and confirm dialog
- Storage utilities and useStorage hook
- Edit view and scenario definition

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 26 tests covering event-storage.ts utilities
- Tests for Date normalization (the bug fix)
- Tests for CRUD operations round-trip integrity
- Tests for edge cases (all-day, multi-day, rapid operations)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- bun run test: run all tests
- bun run test:watch: run tests in watch mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
paulrobello added a commit to paulrobello/claude-canvas that referenced this pull request Jan 13, 2026
Merges PR dvdsgl#8 from dvdsgl/claude-canvas which adds:

Windows Support:
- Cross-platform IPC: TCP sockets on Windows, Unix sockets on Unix/macOS
- Windows Terminal support: split panes and new tabs via wt.exe
- Launcher scripts (.cmd/.ps1) for Windows
- --config-file CLI option for both show and spawn commands

Calendar CRUD:
- Edit scenario with full create/read/update/delete operations
- Events persist to ~/.claude/calendar-events.json
- Modal dialog UI components for event editing
- Keyboard shortcuts: c=create, e=edit, d=delete

Resolved conflict in calendar.tsx (both useMouse and EditView imports needed)
paulrobello added a commit to paulrobello/claude-canvas that referenced this pull request Jan 13, 2026
Documents all functionality added from merged PRs:
- 17 canvas types (14 new from PR dvdsgl#9 + 3 original)
- Mouse scroll wheel support (PR dvdsgl#7)
- Windows support with Windows Terminal (PR dvdsgl#8)
- Calendar CRUD with local storage (PR dvdsgl#8)
- Terminal Vision capture feature (issue dvdsgl#5)
- Shared component library (Charts, Forms, Layout)
- Full CLI command reference
- Canvas examples and keyboard shortcuts
- IPC protocol documentation
- Project structure overview
zepef and others added 14 commits January 14, 2026 11:48
Merges calendar display, meeting picker, and edit views into a single
unified component with comprehensive features:

- View modes: day/week/month with keyboard switching (1/2/3)
- Navigation: arrows, shift+arrows (hour jump), j/k (event jump),
  PageUp/Down (week), Home/End (day start/end), n/p (period), y/Y (year)
- Event management: create (c), edit (e), delete (d) with modal dialogs
- Mouse support: click to select, hover highlighting
- Multi-calendar mode: overlay multiple calendars for meeting scheduling
- Conflict detection: Tab to cycle through overlapping events
- Status line: cursor position, event details, duration, free/busy
- Time column: busy hour indicators, working hours distinction
- Help overlay: press h for keyboard shortcuts reference
- Auto-scroll to current time on startup
- Weekend highlighting, event counts, all-day events row
- Week/day summary showing total events and hours scheduled

Test configs included for regular calendar and meeting picker modes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Documents usage, features, configuration options, and meeting picker mode
for the new unified calendar canvas.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New modules:
- virtual-desktop.ts: PSVirtualDesktop PowerShell wrapper for desktop/window control
- window-manager.ts: Window registry, canvas assignment, session state persistence
- session.ts: Session lifecycle (start/stop/reconnect) and window management

New CLI commands:
- session start/stop/status/reconnect: Manage virtual desktop sessions
- window list/add/close/focus: Manage canvas windows
- assign/swap: Control canvas-to-window assignments
- focus-desktop/home: Navigate between canvas and main desktops
- check-deps: Verify VirtualDesktop module installation

Features:
- Dedicated virtual desktop for canvas windows
- Dynamic window count (user-specified)
- Session persistence for reconnection after restarts
- Canvas swapping between windows
- Window handle tracking and refresh

Requires: Install-Module VirtualDesktop -Scope CurrentUser

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Covers:
- Installation on Windows/macOS/Linux
- Basic canvas commands (show, spawn, update)
- Virtual desktop session management
- Advanced calendar features and keyboard shortcuts
- IPC communication protocol
- Troubleshooting guide
- File structure reference

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add findWtExe() to locate Windows Terminal executable across different
  installation methods (Store, Scoop, Chocolatey)
- Add spawnWtWindow() helper using PowerShell Start-Process for reliable
  window creation
- Fix template literal escaping conflicts in PowerShell command strings
- Add OneDrive module path handling for PowerShell modules
- Add warning suppression for VirtualDesktop module import

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ignore temporary files created by Claude Code sessions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix Promise anti-pattern in cli.ts, canvas-api.ts, and terminal.ts
  (async executors in new Promise() cause unhandled rejections)
- Fix IPC buffer race condition in server.ts by using per-socket buffers
- Add JSON.parse error handling in cli.ts for all config parsing
- Fix PowerShell command injection in virtual-desktop.ts by sanitizing
  user inputs (escaping backticks, dollar signs, and quotes)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add tsconfig.json with proper JSX/React configuration
- Make IPC server and client interfaces generic for bidirectional typing
- Fix JSX.Element → React.JSX.Element across all React components
- Fix color type inference in flight seat components
- Fix null/undefined handling in raw-markdown-renderer
- Fix event-modal unreachable code removal
- Fix event-storage serialization/deserialization types
- Fix session.ts array access and return type annotations
- Fix ipc/client.ts undefined checks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Create useSafeInput wrapper hook that checks process.stdin.isTTY before
enabling Ink's useInput. This prevents "Raw mode is not supported" errors
from being thrown and incorrectly used as React keys when running outside
a proper terminal context.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix silent error swallowing across 19 locations by adding proper
  error messages or explanatory comments for expected failures
- Replace `any` types in IPC code with proper Bun Socket<undefined> types
- Add connection timeout (30s default) separate from selection timeout
- Fix race condition in session window creation with incremental saves
- Replace hardcoded /tmp/ paths with os.tmpdir() for cross-platform support
- Add config validation module with validators for all canvas types
- Add standardized error utilities module for consistent error formatting
- Add comprehensive tests for validation (81 tests) and errors (62 tests)

Test coverage: 250 tests passing, 82% overall line coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add types for grid layout configuration and state
- Add cell calculator for computing grid cell positions and sizes
- Add grid manager for tracking window placement in grid cells
- Add monitor info module for detecting display configuration
- Add window positioner for placing windows on the grid
- Include comprehensive tests for cell calculator and grid manager

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive Grid Management API for positioning canvases on a
grid-based layout system:

- Import and re-export grid types (GridConfig, GridState, CellSpan, etc.)
- Add grid positioning options to SpawnOptions interface
- Add 12 new API functions for grid management:
  - createGridState() - Initialize grid state for a virtual desktop
  - parseGridPosition() - Parse cell specs ("A1", "B2:C3", "0,0:2x2")
  - findAvailableGridPosition() - Find available cells for auto-placement
  - assignToGrid() - Assign window to specific grid position
  - removeFromGrid() - Remove window from grid
  - getGridPosition() - Get window's current position
  - getWindowRect() - Get pixel rectangle for window position
  - getAvailableGridCells() - List unoccupied cells
  - getGridLayout() - Get complete layout info with all assignments
  - formatGridPosition() - Format cell span as Excel notation
  - visualizeGridLayout() - Generate ASCII visualization
  - spawnCanvasInGrid() - Spawn canvas with automatic grid placement

The grid system enables managing multiple canvas windows with automatic
positioning and collision detection on a configurable grid layout.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 66 tests covering all grid API functions in canvas-api.ts:

createGridState (6 tests):
- Default config, custom desktop index, custom/partial config
- Independent states, lastUpdated timestamp

parseGridPosition (10 tests):
- Excel-style cells and ranges (A1, A1:C2)
- Coordinate-style specs (0,0, 1,1:2x3)
- Error handling for invalid/empty strings
- Case insensitivity

findAvailableGridPosition (5 tests):
- Empty grid, requested size, full grid
- After partial occupation, oversized requests

assignToGrid (7 tests):
- String and CellSpan positions
- Error for invalid/occupied/out-of-bounds positions
- Reassignment of same window, multi-cell spans

removeFromGrid (3 tests):
- Window removal, non-existent window, cell reuse

getGridPosition (3 tests):
- Assigned window, non-existent window, multi-cell spans

getWindowRect (2 tests):
- Non-existent window, pixel dimensions for assigned window

getAvailableGridCells (4 tests):
- Empty grid, after occupation, full grid, multi-cell spans

getGridLayout (6 tests):
- Empty grid, assigned windows, window kinds
- Multi-cell spans, dimensions, monitor info

formatGridPosition (4 tests):
- Single cells, ranges in Excel notation

visualizeGridLayout (5 tests):
- String output, grid structure, window names
- Cell references for empty cells

Integration tests (4 tests):
- Complete workflow, multiple windows, parse/format inverse, immutability

Edge cases (8 tests):
- 1x1 grid, large grid, columns beyond Z
- Zero-based indexing, special characters, config preservation
- Coordinate format variants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Ignore generated test data file from flight canvas testing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@blockedby
Copy link

up

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.

2 participants