Skip to content

Conversation

@devxalted
Copy link
Owner

Summary

  • Add persistent port configuration to dev server settings
  • Port is saved to project config.json and applied when starting dev server
  • UI allows setting port via dialog before starting

Changes

Backend

  • get_dev_port() / set_dev_port() functions in project_config.py
  • Port field added to DevServerConfigResponse and DevServerConfigUpdate schemas
  • GET /devserver/config returns configured port
  • PATCH /devserver/config accepts and validates port updates
  • inject_port_into_command() applies port to various project types (Vite, CRA, Django, FastAPI)

Frontend

  • Port selection dialog in DevServerControl component
  • API client updated to pass port on start

Test Plan

  • Set port via UI, verify persists in config.json
  • Start dev server, verify port injection works
  • GET /api/projects/{name}/devserver/config returns port
  • PATCH /api/projects/{name}/devserver/config accepts port

Part 1 of autocoder enhancements from improvements.md

🤖 Generated with Claude Code

Admin and others added 7 commits January 22, 2026 17:52
- Add inject_port_into_command() to project_config.py
  Handles port injection for various project types (Vite, CRA, Django, FastAPI)
- Add port field to DevServerStartRequest schema
- Inject port in devserver router's start endpoint
- Add port selection dialog to DevServerControl UI
- Update API client to pass port parameter

This enables per-start port configuration. Persistent port config (get_dev_port,
set_dev_port, config schema updates) to be added in follow-up.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add get_dev_port(project_dir: Path) -> int | None function following
the existing get_dev_command pattern. Returns the configured dev port
from the project config file, or None if not configured.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add port: int | None = None field to return configured port to the UI.
This completes the schema needed for port configuration feature.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Allows UI to update the configured port via PATCH endpoint
- Follows existing custom_command pattern with optional None value

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Follow existing set_dev_command pattern for consistency
- Validate port range (1-65535) with descriptive ValueError
- Use _validate_project_dir, _load_config, _save_config helpers
- Add function after get_dev_port as specified

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Import get_dev_port from project_config module
- Call get_dev_port(project_dir) to retrieve configured port
- Include port field in DevServerConfigResponse
- Update docstring to document the new port field

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Import set_dev_port from project_config service
- Handle update.port in update_devserver_config function
- Validate port with ValueError handling for invalid values
- Include port field in DevServerConfigResponse

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

@claude please review

@devxalted
Copy link
Owner Author

@claude please review this PR

@devxalted devxalted closed this Jan 23, 2026
@devxalted devxalted reopened this Jan 23, 2026
@devxalted
Copy link
Owner Author

Moved to devxalted/autocoder-dev (non-fork) to enable Claude bot reviews

@devxalted devxalted closed this Jan 23, 2026
devxalted added a commit that referenced this pull request Jan 23, 2026
* feat: add per-start port injection for dev server

- Add inject_port_into_command() to project_config.py
  Handles port injection for various project types (Vite, CRA, Django, FastAPI)
- Add port field to DevServerStartRequest schema
- Inject port in devserver router's start endpoint
- Add port selection dialog to DevServerControl UI
- Update API client to pass port parameter

This enables per-start port configuration. Persistent port config (get_dev_port,
set_dev_port, config schema updates) to be added in follow-up.

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

* feat: add get_dev_port function to project_config

Add get_dev_port(project_dir: Path) -> int | None function following
the existing get_dev_command pattern. Returns the configured dev port
from the project config file, or None if not configured.

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

* feat: add port field to DevServerConfigResponse schema

Add port: int | None = None field to return configured port to the UI.
This completes the schema needed for port configuration feature.

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

* feat: add port field to DevServerConfigUpdate schema

- Allows UI to update the configured port via PATCH endpoint
- Follows existing custom_command pattern with optional None value

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

* feat: add set_dev_port function for persistent port configuration

- Follow existing set_dev_command pattern for consistency
- Validate port range (1-65535) with descriptive ValueError
- Use _validate_project_dir, _load_config, _save_config helpers
- Add function after get_dev_port as specified

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

* feat: add port to devserver GET config response

- Import get_dev_port from project_config module
- Call get_dev_port(project_dir) to retrieve configured port
- Include port field in DevServerConfigResponse
- Update docstring to document the new port field

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

* feat: add port handling to PATCH /devserver/config endpoint

- Import set_dev_port from project_config service
- Handle update.port in update_devserver_config function
- Validate port with ValueError handling for invalid values
- Include port field in DevServerConfigResponse

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

* style: use neo-input class for port input field

Use the standard neo-input class instead of inline styles
to maintain consistency with other form inputs in the UI.

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

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
devxalted added a commit that referenced this pull request Jan 23, 2026
* feat: add git_workflow.py module for core git operations

Implements subprocess-based git operations for the Autocoder agent:
- _run_git(): safe git execution with timeout and error handling
- is_git_repo(), get_main_branch(): repo detection
- generate_branch_name(): slugify feature names for branches
- create_branch(), checkout_branch(), get_current_branch(): branch management
- commit_changes(), push_branch(): commit and push operations
- create_pr(), get_pr_status(): PR operations using gh CLI
- delete_remote_branch(): cleanup operations

Includes additional utilities:
- branch_exists(), create_and_checkout_branch()
- get_commit_sha(), has_uncommitted_changes()

Feature AutoForgeAI#3 - git_workflow.py module

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

* docs: add progress tracking file

Track implementation progress for git workflow features.

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

* feat: add git workflow columns to Feature model

Add 8 new columns for git workflow integration:
- branch_name (indexed): git branch name for this feature
- branch_type: type of branch (feature/bugfix)
- worktree_path: path to git worktree for parallel agent isolation
- commit_sha: SHA of completion commit
- pr_number (indexed): GitHub PR number
- pr_url: full URL to the GitHub PR
- pr_status: current PR status (open/merged/closed)
- merged_at: timestamp when PR was merged

All columns are nullable for backwards compatibility with existing databases.
Includes migration function _migrate_add_git_columns() that safely adds
columns to existing databases using ALTER TABLE.

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

* docs: update progress - Feature #1 git columns complete

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

* feat: add worktree_manager.py module for parallel agent isolation

Implements git worktree management for running multiple agents concurrently:
- _get_worktrees_dir(): Returns worktrees directory path pattern
- create_worktree(): Creates worktree with branch for feature
- remove_worktree(): Removes worktree with shutil fallback
- list_worktrees(): Parses 'git worktree list --porcelain' output
- cleanup_stale_worktrees(): Removes worktrees for passing features

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

* docs: update progress - Feature AutoForgeAI#4 worktree_manager complete

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

* feat: add git workflow Pydantic schemas

Add Pydantic schemas for git-related API endpoints:
- GitConfig, GitConfigUpdate: Git workflow configuration
- GitStatusResponse: Repository status (is_git_repo, current_branch, etc.)
- GitBranchInfo, GitBranchListResponse: Branch information
- GitWorktreeInfo, GitWorktreeListResponse: Worktree information
- GitPRInfo, GitPRListResponse: Pull request information
- Updated FeatureResponse with git fields (branch_name, branch_type,
  worktree_path, commit_sha, pr_number, pr_url, pr_status, merged_at)

Feature AutoForgeAI#5 - Git Pydantic schemas

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

* docs: update progress - Feature AutoForgeAI#5 git schemas complete

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

* feat: add git config helpers to project_config.py

Add GitConfig TypedDict and helper functions for managing git workflow
configuration in projects. This enables per-project git workflow settings
stored in .autocoder/config.json.

- Add GitConfig TypedDict with fields: enabled, auto_branch, auto_commit,
  auto_pr, pr_target_branch
- Add DEFAULT_GIT_CONFIG with sensible defaults (enabled=False, auto_branch=True,
  auto_commit=True, auto_pr=False, pr_target_branch="main")
- Add get_git_config(project_dir) function to load git settings with defaults
- Add set_git_config(project_dir, config) function to save git settings

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

* docs: update progress - Feature AutoForgeAI#2 git config helpers complete

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

* feat: add Git REST API router for git workflow operations

Implements server/routers/git.py with 7 REST endpoints:
- GET /status: Returns git repo status (branch, uncommitted changes, remote)
- GET /config: Returns git workflow configuration
- PUT /config: Updates git workflow configuration (partial updates)
- GET /branches: Lists all local branches with tracking info
- GET /worktrees: Lists all worktrees with feature IDs
- DELETE /worktrees/{feature_id}: Removes worktree for a feature
- GET /prs: Lists pull requests from features.db

Follows existing router patterns from features.py with:
- Lazy imports to avoid circular dependencies
- Project path resolution via registry
- Database session context manager
- Proper error handling with HTTPException

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

* docs: update progress - Feature AutoForgeAI#6 git router complete

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

* feat: add PR watcher service for monitoring merged PRs

Implements background service that polls GitHub for merged PRs every
5 minutes (configurable). On merge detection:
- Updates feature.merged_at in database
- Removes git worktree
- Deletes remote branch

Key components:
- PRWatcher class with configurable poll_interval (default 300s)
- Async _check_merged_prs() queries features via gh CLI
- Async _watcher_loop() runs periodic checks
- start()/stop() for lifespan integration
- Module-level singleton with get_watcher() and cleanup_watcher()

Marks feature AutoForgeAI#9 as passing.

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

* docs: update progress - Feature AutoForgeAI#9 PR watcher service complete

Progress: 7/10 features passing (70%)

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

* feat: add Git MCP tools for agent git operations

- Add git_create_feature_branch(feature_id, branch_type='feature')
  Creates branch using generate_branch_name() and updates feature.branch_name, feature.branch_type

- Add git_commit_feature(feature_id, message)
  Commits changes in feature's worktree (or project dir) and updates feature.commit_sha

- Add git_create_pr(feature_id, title, target_branch='main')
  Pushes branch, creates PR via gh CLI, updates feature.pr_number, pr_url, pr_status

All tools follow existing MCP patterns with proper session handling,
error handling, and JSON return values.

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

* docs: update progress - Feature AutoForgeAI#8 Git MCP tools complete

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

* feat: add git workflow integration to parallel orchestrator

- Add imports for git_workflow, worktree_manager, and project_config
- Load git config in __init__ with fallback to disabled config on error
- Add _update_feature_git_info() helper to update Feature git fields
- Modify _spawn_coding_agent() to create branch/worktree if git enabled
- Add _finalize_git_for_feature() to commit/push/PR after feature passes
- Modify _on_agent_complete() to call git finalization for passed features

Feature AutoForgeAI#7: Orchestrator git hooks

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

* feat: register git router and PR watcher service

- Add git_router export to server/routers/__init__.py
- Import and include git_router in server/main.py
- Start PR watcher service in lifespan startup
- Stop PR watcher service in lifespan shutdown

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

* docs: update progress - Feature AutoForgeAI#10 server registration complete

All 10/10 features now passing (100%)! Git workflow implementation is complete.

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

* fix: security and reliability improvements from code review

- Add branch name validation (is_valid_branch_name) to prevent command injection
- Add feature_id type validation in worktree functions to prevent path traversal
- Replace deprecated asyncio.get_event_loop() with get_running_loop()
- Add thread-safe singleton pattern for PR watcher
- Add try-finally to MCP server lifespan for proper cleanup
- Add validation for pr_target_branch in schemas

Security improvements:
- Branch names now validated against [a-zA-Z0-9/_-]+ pattern
- Path traversal prevented by validating feature_id is positive integer
- Input validation added to all functions that accept user-provided branch names

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

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
devxalted added a commit that referenced this pull request Jan 23, 2026
* feat(database): Add Bug SQLAlchemy model for bug tracking

- Add Bug class with all required fields (severity, source, status, etc.)
- Add to_dict() method for JSON serialization
- Create _migrate_create_bugs_table() migration function
- Register migration in create_database()
- Add BUG_SEVERITIES, BUG_STATUSES, BUG_SOURCES, BUG_CATEGORIES constants

Feature #1: Bug database model - verified complete

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

* docs: update progress notes for Bug database model

Feature #1 complete - Bug SQLAlchemy model implemented

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

* feat(triage): Add bug triage engine for auto-triage and priority scoring

- Create api/bug_triage.py with pattern matching for severity and category
- SEVERITY_PATTERNS: critical, high, medium, low with regex patterns
- CATEGORY_PATTERNS: auth, api, database, ui, testing with regex patterns
- auto_triage_bug(): Analyze title/error/stack_trace to determine severity/category
- compute_priority_score(): Calculate priority from severity, age, and source factors

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

* docs: update progress notes for Bug triage engine

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

* feat(schemas): Add Bug Pydantic schemas for bug tracking API

Added complete set of Pydantic schemas for bug management:
- BugSeverity/BugStatus type aliases with Literal types
- BugCreate: request schema with auto-detect severity option
- BugUpdate: partial update schema with all optional fields
- BugResponse: response schema with all Bug model fields
- BugListResponse: paginated bug list with total count
- BugStatsResponse: statistics with counts by severity/status

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

* docs: update progress notes for Bug Pydantic schemas

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

* feat(api): Add Bug REST API router for bug tracking

- Create server/routers/bugs.py with full CRUD endpoints
- GET /: List bugs with filters (severity, status, limit, offset)
- POST /: Create bug with auto-triage support
- GET /stats: Return bug statistics
- GET/PATCH/DELETE /{bug_id}: Single bug operations
- POST /{bug_id}/retry: Reset bug to 'new' status
- POST /{bug_id}/escalate: Set severity to 'critical'
- Follow existing router patterns (lazy imports, get_db_session)
- Use HTTPException for proper error handling

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

* Fix regression: Register bugs_router in server

- Added bugs_router import in server/routers/__init__.py
- Added bugs_router to __all__ exports
- Added bugs_router import in server/main.py
- Added app.include_router(bugs_router) to register endpoints

The Bug REST API router was implemented but never wired up to the
FastAPI application, making all /api/projects/{name}/bugs endpoints
inaccessible.

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

* feat(ui): Add Bug React hooks for bug tracking API

- Add bug types to ui/src/lib/types.ts (Bug, BugCreate, BugUpdate, BugStats, BugFilters, BugListResponse)
- Add API functions to ui/src/lib/api.ts (getBugs, getBugStats, getBug, createBug, updateBug, deleteBug, retryBug, escalateBug)
- Create ui/src/hooks/useBugs.ts with React Query hooks:
  - useBugs: List bugs with optional filters (10s refetch)
  - useBugStats: Get bug statistics (10s refetch)
  - useBug: Get single bug by ID
  - useCreateBug: Create new bug report
  - useUpdateBug: Update existing bug
  - useDeleteBug: Delete a bug
  - useRetryBug: Reset bug to 'new' status
  - useEscalateBug: Set severity to 'critical'
- All hooks follow established patterns from useRefinement.ts
- Verified with TypeScript compiler (npm run build)

Implements Feature AutoForgeAI#8

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

* docs: update progress notes for Bug React hooks (Feature AutoForgeAI#8)

* feat(ui): Add BugSeverityBadge component for bug tracking

- Create BugSeverityBadge.tsx with severity-based color coding
- Support 'critical', 'high', 'medium', 'low' severity levels
- Show AlertTriangle icon for critical and high severity
- Use neo-badge classes with 'sm' and 'md' size variants
- Color mapping: critical=red, high=orange, medium=yellow, low=gray

Feature AutoForgeAI#9: BugSeverityBadge component - PASSING

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

* docs: update progress notes for BugSeverityBadge (Feature AutoForgeAI#9)

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

* feat(service): Add BugWatcherService for background bug triage

- Create server/services/bug_watcher_service.py following pr_watcher.py pattern
- Implement BugWatcherService class with poll_interval=30s
- Add _poll_bugs() to auto-triage new bugs (severity/category detection)
- Add _check_stale_bugs() to detect bugs stuck >24h in investigating/fixing
- Implement start()/stop() async methods for lifespan integration
- Add module-level singleton: get_bug_watcher(), cleanup_bug_watcher()

Feature AutoForgeAI#5 complete

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

* docs: update progress notes for Bug watcher service (Feature AutoForgeAI#5)

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

* feat(ui): Add BugCard component for bug list display

- Create BugCard.tsx following FeatureCard.tsx pattern
- Display bug severity badge (top-right), title with line-clamp-2
- Show status badge with color coding for all bug statuses
- Display category badge when present
- Show relative created time (e.g., "2h ago") using inline helper
- Show source indicator (API, Webhook, Regression, Test) if not manual
- Use neo-card styling with hover effect
- Feature AutoForgeAI#10 marked as passing

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

* feat(mcp): Add Bug MCP tools for bug management

Implemented 5 new MCP tools for bug tracking and agent assignment:
- bug_get_assigned: Get bug assigned to a specific agent
- bug_update_status: Update bug status with optional notes
- bug_mark_fixed: Mark bug as fixed and ready for testing
- bug_get_next: Get highest priority triaged bugs
- bug_claim: Claim a bug for investigation by an agent

All tools follow existing patterns with:
- @mcp.tool() decorator
- Annotated type hints with Field validation
- JSON return format
- Proper session handling and error rollback

Feature AutoForgeAI#7 - Bug MCP tools - PASSING

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

* docs: Update progress notes for Bug MCP tools (Feature AutoForgeAI#7)

Progress: 9/12 features passing (75%)

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

* feat(server): Register bug watcher service in FastAPI lifespan

- Import get_bug_watcher and cleanup_bug_watcher from bug_watcher_service
- Start bug watcher during lifespan startup (after PR watcher)
- Cleanup bug watcher during lifespan shutdown (after PR watcher cleanup)
- Bugs router was already registered in a previous commit

Feature AutoForgeAI#6: Server registration for bugs - PASSING

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

* docs: Update progress notes for Feature AutoForgeAI#6

- Server registration for bugs now PASSING
- Bug watcher service registered in FastAPI lifespan
- Progress: 10/12 features (83.3%)

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

* feat(ui): Add BugReportModal component for bug reporting

- Create modal form using Radix Dialog for accessibility
- Add form fields: title (required), error message, stack trace (monospace), reproduction steps
- Add optional severity and category selects with auto-detect option
- Use useCreateBug mutation with loading state and error handling
- Follow neobrutalism design with neo-input, neo-btn styling
- Reset form on close, prevent close during submission

Implements Feature AutoForgeAI#12: BugReportModal component

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

* feat(ui): Add BugList component for bug list view

- Implements filterable bug list with severity and status filters
- Uses useBugs hook for data fetching with 10s auto-refresh
- Displays bugs in responsive grid (1/2/3 cols) using BugCard
- Shows loading skeleton while fetching (KanbanBoard pattern)
- Shows empty state when no bugs match filters
- Integrates BugReportModal for creating new bug reports
- TypeScript verified, build passing

Implements Feature AutoForgeAI#11

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

* docs: Update progress notes for Feature AutoForgeAI#11 (BugList component)

All 12 features now passing (100% complete)

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

* fix: address code review issues for bug watcher feature

Critical fixes:
- Add input validation for bug category field against BUG_CATEGORIES
- Add input validation for bug source field against BUG_SOURCES

High priority fixes:
- Add atomic locking to bug_claim MCP tool to prevent race conditions
- Add CHECK constraints to Bug model for data integrity (severity, status, source, category, priority_score)
- Add retry decorator for database lock errors in bugs router

Medium priority fixes:
- Optimize get_bug_stats to use SQL aggregates instead of loading all bugs
- Add text length limit in bug triage to prevent excessive processing
- Fix Path import conflict in refinement.py (pathlib.Path vs fastapi.Path)

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

---------

Co-authored-by: Admin <admin@localhost>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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