Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Codebase structure analysis identified a 2700-line endpoint file mixing routing with business logic, duplicated TCP connection test code across 5 block types, repeated API base URL constants across 7 frontend services, and ~10K lines of committed log/db/backup artifacts.

Backend: service extraction

  • Extract execute_block(), models, and expression evaluators from workflows.py into backend/app/services/block_executor.py
  • workflows.py: 2704 → 754 lines — now purely route definitions
  • Deduplicate 5 nearly identical TCP connection test blocks (SSH/RDP/VNC/FTP/TCP) into _tcp_connection_test():
# Before: ~30 lines repeated per protocol
elif block_type == "connection.ssh_test":
    host = params.get("host", "")
    port = params.get("port", 22)
    import socket
    import time
    sock = socket.socket(...)
    # ... 25 more lines, copy-pasted for rdp/vnc/ftp/tcp

# After: single shared helper
elif block_type == "connection.ssh_test":
    return _tcp_connection_test(
        params.get("host", ""), params.get("port", 22), params.get("timeout", 5)
    )
elif block_type == "connection.rdp_test":
    return _tcp_connection_test(
        params.get("host", ""), params.get("port", 3389), params.get("timeout", 5), protocol="rdp"
    )
  • Inline imports (socket, time, re, subprocess, xml.etree) moved to module-level

Frontend: shared API config

  • New frontend/src/services/apiConfig.ts as single source of truth for API_BASE_URL
  • 7 service files updated to import from shared config
  • Removed dead BlockNode.tsx.bak (347 lines)

Repo hygiene

  • .gitignore: added *.log, *.db, *.bak patterns
  • Removed 14 tracked artifacts: application logs, test.db, timestamped script copies
Original prompt

please analyze codebase and suggest how we can structure our code better and make it smaller and more efficient overall without loosing functionality, respecting industry standard and community best practices

Custom agent used: AKIS
Workflow enforcement agent with 8-gate quality control, skill-based execution, and knowledge graph integration. Orchestrates all other agents.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 6, 2026 15:10
…duplication

- Move BlockExecuteRequest, BlockExecuteResponse, DelayRequest, CodeBlockRequest
  models to backend/app/services/block_executor.py
- Move execute_block(), evaluate_expression(), evaluate_code_expression() to new service
- Deduplicate 5 nearly identical TCP connection test blocks (SSH, RDP, VNC, FTP, TCP)
  into shared _tcp_connection_test() helper
- Move inline imports (socket, time, re, subprocess, xml) to module level
- Reduce workflows.py from 2704 to 754 lines (72% reduction)

Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
… .gitignore

- Remove dead BlockNode.tsx.bak backup file
- Create shared frontend/src/services/apiConfig.ts with API_BASE_URL constant
- Update 7 service files to import from shared config instead of duplicating URL
- Add *.log, *.db, *.bak patterns to .gitignore
- Remove tracked log files, test.db, and timestamped script copies from git

Co-authored-by: goranjovic55 <83976007+goranjovic55@users.noreply.github.com>
Copilot AI changed the title [WIP] Review codebase for better structure and efficiency Refactor: extract block executor service, deduplicate connection tests, clean up repo artifacts Feb 6, 2026
Copilot AI requested a review from goranjovic55 February 6, 2026 15:18
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