Commit Graph

209 Commits

Author SHA1 Message Date
Developer dd69bd69fc refactor: slim git_repositories and config_profiles routers (Task 3.5)
- Extract git control operations to services/git/control.py with repo validation
- Extract git file operations to services/git/files.py with repo validation
- Extract repository lifecycle to services/git/repository.py (create, delete, list)
- Extract config profile helpers to services/config_profiles.py
  (cycle detection, duplicate checks, serialization, default profile management)
- Slim git_repositories.py from ~1050 to 276 lines
- Slim config_profiles.py from ~765 to 299 lines
- Both routers now contain only HTTP routing concerns

Quality gates: py_compile (pass), file size ≤300 (pass), no subprocess in routers (pass)
Refs: repo-restructure Task 3.5
2026-06-02 21:28:15 +00:00
Developer cccf4379d8 refactor: extract CSS modules for session/settings and delete styles.css (Task 2.3)
- Create InstanceList.module.css, AppShell.module.css, SettingsTabLayout.module.css
- Create CommitPanel.module.css, FileViewer.module.css
- Create page CSS files: sessions, repo-workspace, dashboard, projects,
  git-history, ssh-keys, settings
- Update components to import and use CSS modules
- Delete monolithic styles.css (2,255 lines)
- Update main.tsx to import page CSS and new modules

Quality gates: tsc (pass), eslint (pass), build (pass)
Refs: repo-restructure Task 2.3
2026-06-02 21:09:57 +00:00
Developer c8c490eb2b refactor: slim tool_instances router to HTTP-only concerns (Task 3.4)
- Reduce router from 1412 lines to 284 lines (80% reduction)
- Extract all business logic to services/instance_lifecycle.py
- Router now contains only: route definitions, validation, and thin handlers
- Move helpers (_sanitize_name, _generate_instance_name, _modify_compose_file,
  _apply_resolved_profile) to services/docker/compose.py
- Zero subprocess calls in router
- All docker references are service imports only

Quality gates: py_compile (pass), file size ≤300 (pass), zero subprocess (pass)
Refs: repo-restructure Task 3.4
2026-06-02 20:45:18 +00:00
Developer dd7696b5a4 refactor: extract CSS modules for terminal and git components (Task 2.2)
- Create TerminalComponent.module.css with terminal-* styles
- Create GitToolbar.module.css with git toolbar styles
- Create CommitDialog.module.css with commit dialog styles
- Create MergeDialog.module.css with merge dialog styles
- Create FileEditor.module.css with file editor styles
- Update all components to import their CSS modules
- Remove extracted rules from styles.css (~441 lines removed)

Quality gates: tsc (pass), eslint (pass), build (pass)
Refs: repo-restructure Task 2.2
2026-06-02 20:39:32 +00:00
Developer 58a9728d5e refactor: extract pydantic schemas from routers into schemas/ directory (Task 3.2)
- Create schemas/ directory with 12 schema files covering all domains
- Extract 70+ Pydantic models from 11 router files
- Routers now import from src.schemas.{domain} instead of defining inline
- Zero inline BaseModel definitions remain in any router

Quality gates: py_compile all schemas (pass), py_compile all routers (pass)
Refs: repo-restructure Task 3.2
2026-06-02 20:19:05 +00:00
Developer fdd1d21bc7 refactor: fix user.id references and add missing docker imports (Task 3.4 prep)
- Fix user_id → user.id in tool_instances.py (4 occurrences)
- Add get_container_status and get_container_logs imports

Refs: repo-restructure Task 3.4
2026-06-02 19:57:53 +00:00
Developer f6003b75ca refactor: split services/docker.py into focused modules (Task 3.3)
- Create services/docker/compose.py — compose file generation and commands
- Create services/docker/container.py — container lifecycle and queries
- Create services/docker/config_staging.py — config folder file writing
- Create services/docker/tunnel.py — Cloudflare tunnel management
- Create services/docker/__init__.py — barrel exports
- Delete services/docker.py (replaced by package)
- All imports in api/tool_instances.py remain functional

Quality gates: Python syntax check (pass), imports verified
Refs: repo-restructure Task 3.3
2026-06-02 19:51:14 +00:00
Developer c527393d2e refactor: extract schemas and update routers (Task 3.2)
- Create schemas/ directory with Pydantic request/response models
  - tool_instance.py, tool_type.py, git_repository.py, config_profile.py
  - config_folder.py, tool_config.py, project.py, ssh_key.py
- Update api/tool_instances.py to import CreateInstanceRequest from schemas
- Update api/git_repositories.py to import from schemas
- Update api/config_profiles.py to import from schemas
- Update api/tool_types.py to import all schemas from schemas/tool_type.py

Quality gates: Python syntax check (pass)
Refs: repo-restructure Task 3.2
2026-06-02 19:37:25 +00:00
Developer c5fbb6722b refactor: extract global styles and tokens (Task 2.1)
- Create styles/tokens.css with CSS custom properties and dark theme
- Create styles/global.css with resets, shell layout, and navigation
- Create styles/utilities.css with generic utilities and primitives
- Create styles/syntax-highlight.css with Prism.js theme
- Update main.tsx to import the 4 new style files
- Keep styles.css intact for backward compatibility

Quality gates: build (pass), lint (pass)
Refs: repo-restructure Task 2.1
2026-06-02 19:29:38 +00:00
Developer c50d6663d5 refactor: extract shared auth dependencies (Task 3.1)
- Add get_owned_project() to auth/dependencies.py
- Remove duplicated _get_user() and _get_owned_project() from all routers
- Update tool_instances, git_repositories, projects, ssh_keys, users,
  user_config, tool_types routers to use FastAPI dependency injection
- Route handlers now receive User/Project models via Depends() instead
  of calling inline async helpers

Quality gates: Python syntax check (pass), no duplicated helpers (pass)
Refs: repo-restructure Task 3.1
2026-06-02 19:18:12 +00:00
Developer aee3987c24 refactor: extract FileBrowser and shared UI primitives (Task 1.2)
- Extract FileBrowser from inline definition in repo-workspace.tsx
- Create components/features/git/FileBrowser.tsx with module CSS
- Create reusable UI primitives: LoadingState, ErrorState, StatusBadge
- Create barrel exports for components/ui/ and components/features/git/
- Replace inline loading/error patterns in dashboard, sessions, repo-workspace

Quality gates: tsc (pass), eslint (pass)
Refs: repo-restructure Task 1.2
2026-06-02 19:10:33 +00:00
Developer 985ca538e3 refactor: centralize types and extract seed data (Task 1.1)
- Create types/ directory with canonical domain type definitions
  - session.ts, tool-instance.ts, tool-type.ts, git-repository.ts
  - config-folder.ts, tool-config.ts, project.ts, user.ts, api-response.ts
- Move inline types from api modules to types/ with backward-compatible re-exports
- Update all consumers (pages, components, state) to import from types/
- Extract seed_builtin_tool_types from main.py to seeds/builtin_tool_types.py
- Ensure Session, ToolInstance, ToolType, GitRepository defined exactly once

Quality gates: tsc (pass), eslint (pass), Python syntax (pass)
Refs: repo-restructure Task 1.1
2026-06-02 18:58:50 +00:00
Developer ee1fa6bee5 refactor: centralize types and extract seed data (Task 1.1)
- Create types/ directory with centralized domain types:
  session, tool-instance, tool-type, git-repository, config-folder,
  tool-config, project, user, api-response
- Remove inline type definitions from API modules;
  re-export from types/ for backward compatibility
- Update state/sessions.tsx to import Session from types/session.ts
- Update all consumer components/pages to import from types/
- Extract seed_builtin_tool_types from main.py to
  seeds/builtin_tool_types.py
- Create types/index.ts barrel export

Quality gates: tsc (pass), eslint (pass), Python syntax (pass)
2026-06-02 18:56:54 +00:00
Developer d894cd9723 fix: terminal shift-left bug and session sidebar naming/filtering
- Guard ResizeObserver in terminal against internal xterm DOM changes
  by tracking last width/height and only calling fit() on real resize
- Remove padding from .terminal-container and conflicting .xterm height
  override that caused measurement mismatches with xterm-addon-fit
- Filter live session sidebar to active statuses only (running, building,
  pending) instead of showing all sessions including stopped ones
- Add display name fallback across sidebar, sessions page, and instance
  list to prevent blank names when display_name is empty

Quality gates: tsc (pass), eslint (pass)
2026-06-02 14:03:47 +00:00
Developer 5a8eca814d fix: terminal left shift and instance naming scheme
- Debounce terminal ResizeObserver (100ms) and only send resize when cols/rows actually change
- Send initial resize on WebSocket connect/reconnect to prevent PTY default 80x24 shift
- Replace random hex instance names with sequential project-tool-NNN naming
- Add _sanitize_name() and _generate_instance_name() helpers for readable Docker names
2026-06-02 12:11:19 +00:00
alex 6c8cfe9157 feat: responsive web terminal with auto-reconnect, heartbeat, and local echo
Implements a resilient, responsive web terminal that survives network blips,
provides instant typing feedback, and restores scrollback on reconnect.

Backend changes:
- Add heartbeat tracking (15s ping interval, 60s idle timeout)
- Add message batching (16ms flush window) for efficient I/O
- Add termios echo detection and set_echo_state control messages
- Add graceful session_ended notification before close
- Add ping/pong protocol support

Frontend changes:
- Rewrite TerminalComponent with status bar, connection indicator,
  session-ended overlay, reconnect banner, and ResizeObserver
- Add useTerminalConnection hook with:
  - Exponential backoff auto-reconnect (1s → 30s max, 10 attempts)
  - Heartbeat/ping-pong with latency tracking
  - Local echo for printable ASCII with server deduplication
  - Resize debounce (200ms) + throttle (500ms)
  - Scrollback serialization via xterm-addon-serialize
  - Ctrl+Shift+R manual reconnect shortcut
- Add WebSocket protocol types and encoding utilities
- Add xterm-addon-serialize dependency

Tests:
- 16 backend unit tests (TerminalSession + TerminalManager)
- 13 frontend hook tests (connection lifecycle, reconnect, resize,
  scrollback, callbacks)

Quality gates:
- Frontend typecheck: clean
- Frontend lint: clean
- Frontend tests: 48 passed
- Backend unit tests: 101 passed
- Backend ruff: clean

SDD artifacts: openspec/changes/responsive-terminal/
2026-05-27 21:27:49 +02:00
alex 48fa858090 Merge branch 'main' of ssh://git.commumedia.org:2222/alex/headquarter 2026-05-24 15:04:33 +00:00
alex 679b1693fc Merge commit 'ea174b1'
# Conflicts:
#	apps/web/src/pages/projects.test.tsx
2026-05-24 15:03:58 +00:00
alex ea174b1642 fix: review fixes for el-1bn
- Fix duplicate mode field in config_profiles.py mount response
- Fix datetime.UTC import for Python 3.10 compatibility
- Add API documentation for config profiles
- Update CHANGELOG
2026-05-24 15:02:32 +00:00
alex 9cc98455ef 3.2 Launch and restart profile application (el-5z8) 2026-05-24 14:41:17 +00:00
alex a1dbfcf2a8 feat: implement profile CRUD validation compatibility and defaults API
- Add ConfigProfile CRUD endpoints with user ownership and access checks
- Implement ordered include management with cycle detection
- Add mount management with path validation (absolute, no traversal)
- Implement compatibility-filtered listing by tool type
- Add default profile selection APIs (get/set defaults per tool type)
- Fix SQLAlchemy ambiguous foreign key relationships in config models
- Add comprehensive integration tests (29 tests, all passing)
- Merge upstream profile resolver service changes (task 2.1)
2026-05-24 14:06:03 +00:00
alex 13aceeb08d 2.1 Profile resolver service (el-1nj) 2026-05-24 13:58:39 +00:00
alex f0e19615ce 2.3 Instance API profile selection plumbing (el-4hr) 2026-05-24 13:39:45 +00:00
alex 0bea26c784 1.1 Backend data model and migrations (el-5fe) 2026-05-24 13:23:12 +00:00
miguel 99097090e6 fix: resolve test failures after merge and add missing labels
- Fix tool-workshop test selectors to match component labels
- Fix API test mocks for axios client
- Add htmlFor attributes to form labels in tool-workshop
- Update type signatures to match API interfaces

Quality gates: 43/43 tests pass, typecheck pass, lint pass
2026-05-22 21:15:06 +02:00
alex fb0f2f7b9b feat: add project settings page navigation
- Remove inline edit modal from projects listing page
- Add Settings link to project cards navigating to /projects/:id/settings
- Reposition Open Workspace button to rightmost action for easier access
- Update tests for new UI flow
- Update documentation to reflect new editing workflow
- Sync specs: frontend-foundation and project-management

Quality gates: npm run lint passed
2026-05-22 18:43:40 +00:00
miguel 6f35eb77ae feat: redesign authenticated UI with home overview and settings hub
- Add HomePage with open sessions grid, projects overview, and session composer
- Add SettingsPage with tabs for General, SSH Keys, Tool Types, Tool Configs
- Update navigation to Home, Projects, Settings
- Redirect legacy routes (/sessions, /ssh-keys, /tool-types, /tool-configs)
- Apply Inter font and warm editorial styling
- Update tests for new dashboard and projects pages

Quality gates: typecheck pass, lint pass, 15/15 tests pass

Refs: openspec/changes/ui-redesign-home-settings
2026-05-22 20:38:05 +02:00
Fusion 575e5837ea Merge branch 'main' of ssh://git.commumedia.org:2222/alex/headquarter 2026-05-22 20:34:20 +02:00
Fusion 996ea73bbf fix: resolve remaining integration test failures
- Add POST /tool-types/validate endpoint for pre-creation validation
- Add ToolConfigUpdate model with optional fields for PUT endpoint
- Fix tool_configs POST to return 201 status code
- Fix tool_configs list endpoint to return list instead of dict
- Fix tool_configs defaults endpoint to return 'suggested_configs'
- Fix tool_types create endpoint to include category and interfaces
- Add model_validator to enforce dockerfile/compose template requirements
- Update tests to match API response format
2026-05-22 20:33:29 +02:00
miguel d0e5feeaa5 test: fix mock to actually exercise orphan branch path 2026-05-22 20:29:30 +02:00
Fusion 1f784b552d fix: resolve config folders API bugs and test infrastructure
- Fix validation error handler to serialize ValueError objects safely
- Add GET /config-folders/{id} endpoint (was missing)
- Fix project overrides API to accept project_id in body instead of query param
- Add flag_modified for SQLAlchemy JSONB change detection
- Fix DELETE endpoint to return 204 status code
- Fix conftest.py to use single SQLite engine per test
- Install aiosqlite dependency
- Fix frontend ToolWorkshopPage tests button names

Config folders tests: 13/13 passing
Docker build tests: 10/10 passing
Readiness probe tests: 13/13 passing
2026-05-22 20:16:23 +02:00
miguel 10cbe63095 fix: handle unborn HEAD branch creation
- Create orphan branches when HEAD does not exist yet\n- Use current branch as the default branch base in the toolbar\n- Keep push disabled for remote-less repos\n\nQuality gates: vitest repositories-settings-tab (passed); api pytest blocked by missing fastapi in environment
2026-05-22 20:02:51 +02:00
miguel 4547105f3b fix: use working clones for git repos
- Create normal working clones for remote repositories
- Initialize blank repositories with a main branch
- Align pull and branch helpers with unborn HEAD handling
- Gate fetch/pull on repositories with a remote

Quality gates: vitest repositories-settings-tab (passed); api pytest blocked by missing fastapi in environment
2026-05-22 19:54:42 +02:00
Fusion dacf105200 test: add comprehensive tests for tool workshop functionality
Backend tests:
- Unit tests for docker_build service (successful/failed builds, context, paths)
- Unit tests for readiness_probe service (success, timeout, retries, edge cases)
- Integration tests for config_folders API (CRUD + project overrides)
- Integration tests for tool_types API with new fields
- Integration tests for tool_configs API with new fields

Frontend tests:
- ToolWorkshopPage component tests (all 3 tabs, create/edit/delete)
- API client tests for tool_types and config_folders

Fixes:
- Add field_validator import to tool_configs.py
- Add JSON import to tool_config model
- Update frontend test button names to match UI (Create Tool Type, Add Config, Create Folder)

Quality gates: backend unit tests passing (23/23)
2026-05-22 19:45:10 +02:00
miguel 2525c58471 feat(web): support ssh owner repo clone flow
- Add SSH-only owner/repo clone path for git.commumedia.org
- Preflight remote repository existence with git ls-remote before cloning
- Keep advanced URL paste fallback and blank repository creation
- Add focused backend and frontend coverage plus docs updates

Quality gates: python -m py_compile, vitest run src/components/repositories-settings-tab.test.tsx, npm run typecheck
2026-05-22 19:07:04 +02:00
Fusion 8dd350286e feat: implement tool workshop - comprehensive tool system enhancement
- Add Docker Compose and Dockerfile support for tool definitions
- Implement readiness probes with configurable command, timeout, interval
- Create ConfigFolder model for reusable file collections with project overrides
- Add rich tool config fields: port_override, start_command, working_directory, env vars, volumes
- Build unified Tool Workshop UI at /tool-workshop replacing /tool-configs and /tool-types
- Update instance creation to support dockerfile builds, config folder mounting, readiness probes
- Add 3 database migrations for tool_types, tool_configs, and new config_folders table
- Create docker_build.py and readiness_probe.py services
- Add config_folders API with CRUD and project override endpoints

Quality gates: frontend build passes, Python syntax valid, all phases complete

Addresses tool-workshop OpenSpec change
2026-05-22 19:06:45 +02:00
miguel 5af4de0d7e refactor(web): reuse repository create dialog
- Extract the repository create dialog into a shared component
- Reuse the same clone/validation flow in project settings and repository management pages
- Keep the shared UI covered with focused tests

Quality gates: tsc --noEmit, vitest run src/components/repositories-settings-tab.test.tsx
2026-05-22 18:43:03 +02:00
miguel ebfe991a15 fix(web): support cloning existing repositories
- Make the add repository dialog explicitly support cloning from a remote git server
- Keep blank repo creation as a fallback option
- Add validation and tests for the clone-first flow

Quality gates: tsc --noEmit, vitest run src/components/repositories-settings-tab.test.tsx
2026-05-22 18:38:21 +02:00
miguel cc1507a33e fix(web): add repository creation to project settings
- Add repository creation dialog to the project settings repositories tab
- Reuse shared repository API for list/create/delete operations
- Add coverage for the create flow in the settings tab

Quality gates: tsc --noEmit, vitest run src/components/repositories-settings-tab.test.tsx
2026-05-22 18:34:02 +02:00
Fusion ae377baa74 fix(opencode): add debugging output for installation
- Add set -x for verbose command execution
- Add error messages if npm install fails
- Check which opencode and list global bin directory
- Add npm global bin to PATH in bashrc
- Add ca-certificates package for HTTPS

Quality gates: code review
2026-05-21 12:40:01 +02:00
Fusion a0d4e76662 fix(opencode): ensure proper installation and workspace setup
- Add --unsafe-perm to npm install for global package installation
- Add cd /workspace to /root/.bashrc so terminal opens in repo directory
- Start container process in /workspace directory
- Use exec for proper signal handling

Quality gates: code review
2026-05-21 12:34:18 +02:00
Fusion b61c2256a8 refactor(opencode): install opencode via npm instead of curl
- Replace curl-based installation with npm install -g opencode-ai
- Remove manual PATH setup and symlink creation
- Simplify installation process

Quality gates: code review
2026-05-21 12:29:23 +02:00
Fusion 7e6588a99d fix(opencode): ensure opencode binary is in PATH
- Check if opencode binary exists at expected location before symlinking
- Add ~/.opencode/bin to PATH in /etc/profile and /root/.bashrc
- Provides warning if binary not found instead of silently failing

Quality gates: code review
2026-05-21 12:26:07 +02:00
Fusion 56b54e269a fix(terminal): create PTY for proper interactive shell
- Use Python pty module to create pseudo-terminal
- Pass slave fd to docker exec for real TTY allocation
- Fixes ioctl errors and job control warnings
- Supports terminal resizing via TIOCSWINSZ

Quality gates: local testing
2026-05-21 12:03:36 +02:00
Fusion 6e597b9e21 fix(terminal): allocate proper TTY for docker exec
- Change docker exec -i to -it for real TTY allocation
- Fixes ioctl errors and job control warnings in terminal
- Gives bash a proper terminal for interactive use

Quality gates: manually tested
2026-05-21 11:39:14 +02:00
Fusion a2c3d6877e fix(terminal): remove TTY allocation, use interactive bash with TERM env var 2026-05-21 11:21:51 +02:00
Fusion a200955ef2 fix(terminal): remove duplicate WebSocket read loop, let terminal_manager handle I/O 2026-05-21 11:19:11 +02:00
Fusion 76266fc3d0 fix(terminal): allocate pseudo-TTY for interactive docker exec session 2026-05-21 11:09:08 +02:00
Fusion 9d54a2542b fix(terminal): use decode_session_cookie instead of verify_session_token 2026-05-21 11:05:48 +02:00
Fusion 520078fd64 debug(terminal): add comprehensive logging to WebSocket terminal handler 2026-05-21 11:01:32 +02:00