Skip to content

feat: add Connect to Pixel Agents terminal context menu#53

Open
pghoya2956 wants to merge 3 commits intopablodelucca:mainfrom
pghoya2956:feat/auto-detect-manual-sessions
Open

feat: add Connect to Pixel Agents terminal context menu#53
pghoya2956 wants to merge 3 commits intopablodelucca:mainfrom
pghoya2956:feat/auto-detect-manual-sessions

Conversation

@pghoya2956
Copy link

@pghoya2956 pghoya2956 commented Feb 28, 2026

Summary

  • Add "Connect to Pixel Agents" terminal tab context menu for manually connecting a terminal running Claude to a pixel character
  • Improve auto-adoption: when only 1 unowned terminal exists, adopt it automatically (no focus required)
  • Extract AgentState factory (agentFactory.ts) to eliminate 4-site initialization duplication
  • Fix passive wheel event listener warning in OfficeCanvas

Problem

Previously, only terminals created via the "+ Agent" button were tracked. Users running claude directly in a terminal got no character. The auto-detection logic only tried the focused terminal, which was timing-dependent and failed entirely with multiple terminals.

Solution

Manual connect (primary path): Terminal tab right-click → "Connect to Pixel Agents" → resolves project dir → finds best untracked JSONL by mtime → creates character. Works reliably with any number of terminals.

1:1 auto-adopt (convenience): When a new JSONL file appears and exactly 1 unowned terminal exists, auto-adopt without requiring focus.

image

Changes

File Change
src/constants.ts COMMAND_CONNECT_TERMINAL constant
package.json Command declaration + terminal/title/context menu
src/extension.ts Command handler registration
src/PixelAgentsViewProvider.ts connectTerminal(), resolveProjectDir(), findBestJsonlFile()
src/fileWatcher.ts 1:1 auto-adopt logic + exported adoptTerminalForFile with guard
src/agentFactory.ts New: createAgentState() factory
src/agentManager.ts Uses factory, reduced duplication
webview-ui/src/office/components/OfficeCanvas.tsx Wheel handler: passive → active event listener
CLAUDE.md Architecture docs updated

Test plan

  • Terminal right-click shows "Connect to Pixel Agents" menu
  • Click menu on terminal running claude → character appears
  • Click menu on already-connected terminal → info message
  • Click menu on terminal without Claude session → warning message
  • Single terminal + claude → auto character creation (no focus needed)
  • Multiple terminals → no auto-adopt, use right-click menu
  • "+ Agent" button → existing behavior unchanged
  • Character click → terminal focuses
  • Terminal close → character removed

🤖 Generated with Claude Code

Heeho Lim and others added 3 commits February 28, 2026 23:10
- Create agentFactory.ts with createAgentState() to eliminate 4-site duplication
- Apply factory in agentManager.ts (launchNewTerminal, restoreAgents)
- Fix OfficeCanvas wheel handler: use DOM addEventListener with { passive: false }
  instead of React onWheel to allow preventDefault without console warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Export adoptTerminalForFile for reuse by other modules
- Add terminal double-adoption guard (prevents same terminal from being adopted twice)
- Return number | null (adopted agent ID or null if skipped)
- Use createAgentState factory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add terminal tab right-click → "Connect to Pixel Agents" command
  for manually connecting a terminal running Claude to a character
- Resolve project dir via shellIntegration.cwd → creationOptions.cwd
  → single-root workspace fallback
- Find best untracked JSONL file by mtime, skip past history
- Improve auto-adoption: when only 1 unowned terminal exists,
  adopt it automatically without requiring focus
- Update CLAUDE.md with new architecture entry and adoption docs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ziomik pushed a commit to ziomik/pixel-agents that referenced this pull request Mar 5, 2026
Implemented multi-building town layout with worker movement based on workflow state.

## What's Implemented

### Building Zones System
- Created buildingZones.ts with 7 building definitions:
  - Planning Area (3 seats, whiteboards)
  - To Do Office (3 seats, desks)
  - Doing Office (8 seats, desks + computers)
  - Review Room (4 seats, meeting table)
  - Testing Lab (4 seats, testing stations)
  - Done Lounge (4 seats, relaxation area)
  - Park (4 seats, benches)
- Each building has bounds, seat IDs, entry points for pathfinding

### Town Layout
- Created townLayout.ts with complete furniture placement
- 30x24 tile grid with buildings in distinct zones
- Proper desk+chair combinations for auto-facing detection
- Decorations (plants, cooler, whiteboards, PCs)
- Walkable floor with wall boundaries

### Movement Logic
- Created buildingMovement.ts with:
  - moveCharacterToBuilding() - finds seat, calculates path, moves worker
  - isCharacterInBuilding() - checks if already in target building
  - Automatic seat assignment within buildings
  - Pathfinding integration (uses existing A* from tileMap)

### Data Integration
- Extended DevClawWorker interface with currentBuilding field
- Backend sends: 'doing' | 'review' | 'testing' | 'done' | 'park' | 'planning' | 'todo'
- Defaults: active workers → 'doing', idle → 'park'

### DevClawApp Updates
- Uses townLayout instead of default office layout
- Initial spawn: assigns workers to correct building based on currentBuilding
- useEffect listener: moves workers when currentBuilding changes
- Proper seat assignment and collision handling

## Acceptance Criteria

✅ Town layout includes all 6+ building types
✅ Workers spawn in correct buildings based on initial state
✅ Workers walk (with animation) when currentBuilding changes
✅ Collision detection works (uses existing tileMap system)
✅ Multiple workers can be in same building (multiple seats per building)
✅ Zoom level preserved (4x, already configured)

Note: Office tileset (office-tileset.png) exists in public/assets but not
integrated into renderer - current implementation uses pixel-agents default
sprites with new layout structure. Tileset rendering would require deeper
changes to sprite system.

## Files

- webview-ui/src/office/layout/buildingZones.ts (new)
- webview-ui/src/office/layout/townLayout.ts (new)
- webview-ui/src/office/engine/buildingMovement.ts (new)
- webview-ui/src/hooks/useDevClawData.ts (updated)
- webview-ui/src/DevClawApp.tsx (updated)
- webview-ui/src/devclawApi.ts (new - WebSocket helper)
- webview-ui/src/main.tsx (updated - DevClawApp integration)
- webview-ui/src/vscodeApi.ts (updated)
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.

1 participant