Skip to content

Remove Python dependency, Go-only codebase#12

Merged
mudrii merged 9 commits intomainfrom
remove-python-dependency
Mar 22, 2026
Merged

Remove Python dependency, Go-only codebase#12
mudrii merged 9 commits intomainfrom
remove-python-dependency

Conversation

@mudrii
Copy link
Copy Markdown
Owner

@mudrii mudrii commented Mar 22, 2026

Summary

  • Remove all Python code (server.py, system_metrics.py, tests/, requirements.txt) — the dashboard is now 100% Go with zero external dependencies
  • Reorganize into internal packages (appconfig, appserver, appchat, apprefresh, appruntime, appsystem) with clean separation of concerns
  • Comprehensive error handling hardening — 15 silent failure fixes including UserHomeDir, json.Marshal, config loading fallbacks, gateway timeout classification (502→504)
  • Add linting infrastructure — .golangci.yml, Makefile, golangci-lint CI step; 0 lint issues
  • Add 37 new tests across 4 previously untested internal packages; all 121 tests pass with -race
  • Fix all documentation — TECHNICAL.md, CONFIGURATION.md, README.md, Dockerfile, goreleaser, bug report template, package doc comments
  • Remove dead code — unused constants, type aliases, empty files, unreachable branches

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test -race -count=1 ./... — all 121 tests pass
  • golangci-lint run ./... — 0 issues
  • Binary builds and runs with correct flags (--help, --version, --refresh)
  • All HTTP endpoints preserved (/, /api/refresh, /api/system, /api/chat)
  • No functional behavior changes — only error handling hardening, dead code removal, docs, and tests

🤖 Generated with Claude Code

mudrii and others added 9 commits March 9, 2026 18:59
- index.html: change 'v__VERSION__' → '__RUNTIME__ · v__VERSION__' in
  the top-right GitHub version link so the server runtime is shown inline
  (e.g. 'Go · v2026.3.8' or 'Python · v2026.3.8')

- index.html (JS): strip leading 'OpenClaw ' prefix from currentVersion
  before building sysOclaw pill text — prevents 'OpenClaw OpenClaw ...'
  duplication when openclaw status --json already includes the prefix

- server.go: inject '__RUNTIME__' → 'Go' in NewServer() alongside __VERSION__

- server.py: inject '__RUNTIME__' → 'Python' in _render_index() alongside __VERSION__

- server_test.go: add TestIndex_RuntimeInjected (Go=Go, no raw placeholder)

- tests/test_frontend.py: add TestRuntimeBadge (4 assertions: placeholder
  present in HTML, separator pattern, rawInst var, prefix-strip regex)

- tests/test_server.py: add TestRenderIndex (Python injection + __VERSION__
  still replaced)

Backward-compatible: if a runtime doesn't replace __RUNTIME__, it appears
as literal '__RUNTIME__' (safe, visible signal — not silently broken).
currentVersion may carry a build suffix like '2026.3.8 (3caab92)'.
Introduce instNorm by stripping the '(...)' part before comparing
against latestVersion, so equal releases are not shown as outdated.
Remove server.py, system_metrics.py, all Python tests, and embedded
Python from refresh.sh. Data collection logic ported to Go (refresh.go)
with --refresh flag. All docs, scripts, Dockerfile, and GitHub templates
updated to reflect Go-only architecture.

- Delete: server.py, system_metrics.py, requirements.txt, tests/, .pytest_cache
- Add: refresh.go (~1000 lines) — full Go port of data collection
- Add: --refresh flag to main.go for standalone data.json generation
- Rewrite: refresh.sh (901→40 lines), install.sh, uninstall.sh, Dockerfile
- Update: README, TECHNICAL, CONTRIBUTING, ARCHITECTURE, CONFIGURATION,
  CHANGELOG, TODO, BENCHMARK, GitHub issue/PR templates
- Remove stale Python comments from chat.go, system_service.go, version.go
- All Go tests pass with -race detector

Made-with: Cursor
Bug fixes:
- Replace deprecated strings.Title with titleCase() helper
- Fix IPv6 rate-limiter IP extraction using net.SplitHostPort
- Fix slice mutation in collectTokenUsage (safe pre-allocated copy)

Performance:
- Cache resolveOpenclawBin() via sync.Once in SystemService
- Pass pre-loaded Config to runRefreshCollector (skip re-read)
- Stream JSONL files with bufio.Scanner instead of os.ReadFile
- Parallelize collectGatewayHealth/collectCrons/collectGitLog

Tests (23 new):
- modelName, fmtTokens, titleCase, trimLabel
- filterByDate, limitSlice, buildAlerts (7 cases)
- collectCrons (4 cases), buildCostBreakdown, bucketsToList
- buildDailyChart, buildSIDToKeyMap, runRefreshCollector variadic

Made-with: Cursor
- Fix data race on RefreshCollectorFunc: replace mutable global var
  with a refreshFn field on appserver.Server injected at construction.
  Restructure tests to set mocks before server creation.
- Fix Dockerfile: add missing COPY for internal/ and cmd/ directories
  so the Docker build succeeds with the new package layout.
- Pass pre-loaded Config in main.go --refresh CLI path to avoid
  redundant config re-read from disk.
- Fix getLatestVersionCached: only cache timestamp on successful npm
  lookup so failures don't block retries for the full TTL.
- Update go.mod from go 1.23 to go 1.26 to match toolchain.
- Remove duplicate .DS_Store entry in .gitignore.

Made-with: Cursor
- Fix 15 silent failure issues: proper error handling for UserHomeDir,
  json.Marshal, config loading, dotenv parsing, session/token caches,
  gateway timeout (502→504), and sort comparator panic guard
- Remove dead code: empty refresh_sessions.go, unused constants
  (maxBodyBytes, maxQuestionLen, chatRateLimit, maxGatewayResp),
  unused type aliases and functions in root package
- Fix all lint issues: errcheck (defer Close patterns), ineffassign,
  unreachable strings.Contains after filepath.Clean
- Add linting infrastructure: .golangci.yml, Makefile with lint/test/
  build targets, golangci-lint CI step in tests.yml
- Add 37 new tests across 4 internal packages (appconfig, appserver,
  appchat, appruntime) + extend appsystem tests — coverage for
  previously untested packages
- Fix all documentation: TECHNICAL.md version/data-flow/theme refs,
  CONFIGURATION.md missing system config and env vars, README.md
  stale refresh.sh refs, Dockerfile VERSION file and unused packages,
  goreleaser port fix, bug report template, package doc comments
- Add .claude/ to .gitignore, remove tracked settings.local.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mudrii mudrii merged commit cf53bf5 into main Mar 22, 2026
1 of 3 checks passed
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request marks a significant architectural shift by fully migrating the dashboard's backend from Python to Go. The core purpose was to eliminate external runtime dependencies, enhance performance, and improve maintainability. The changes involve a complete rewrite of Python components in Go, structured into well-defined internal packages, alongside robust error handling, new linting, and expanded test coverage. This results in a more self-contained, reliable, and efficient dashboard application.

Highlights

  • Python Codebase Removal: Completely removed all Python code, including server.py, system_metrics.py, tests/, and requirements.txt, making the dashboard 100% Go with zero external dependencies.
  • Code Reorganization: Reorganized the codebase into new internal Go packages (appconfig, appserver, appchat, apprefresh, appruntime, appsystem) to ensure clean separation of concerns.
  • Error Handling Hardening: Implemented comprehensive error handling improvements, fixing 15 silent failures and refining gateway timeout classification (502 to 504).
  • Linting Infrastructure: Added a new linting infrastructure with .golangci.yml, Makefile integration, and a golangci-lint CI step, resulting in zero lint issues.
  • Test Suite Expansion: Added 37 new tests across 4 previously untested internal packages, ensuring all 121 tests pass with the -race detector.
  • Documentation Updates: Fixed and updated all relevant documentation files, including TECHNICAL.md, CONFIGURATION.md, README.md, Dockerfile, goreleaser, and bug report templates.
  • Dead Code Removal: Removed unused constants, type aliases, empty files, and unreachable code branches to streamline the codebase.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/label-issues.yml
    • .github/workflows/release.yml
    • .github/workflows/tests.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mudrii mudrii deleted the remove-python-dependency branch March 22, 2026 16:36
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is an impressive and well-executed pull request. The complete removal of the Python dependency and the migration to a pure Go codebase is a significant undertaking. The changes are thorough, consistent, and of high quality. I'm particularly impressed by:

  • The clean refactoring of the Go code into internal packages, which greatly improves maintainability.
  • The comprehensive updates to documentation, CI/CD configuration (Dockerfile, goreleaser, Makefile), and project templates, ensuring the entire developer and user experience is aligned with the new Go-only architecture.
  • The numerous robustness improvements, such as the enhanced graceful shutdown, more resilient binary/asset path resolution, and better handling of version strings.
  • The addition of a solid testing foundation for the new Go packages.

Overall, this is an excellent contribution that significantly improves the project's architecture, simplifies its dependencies, and sets it up for future success. I have no specific comments on the code changes as they are all well-implemented and consistent with the goals of the PR.

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