Skip to content

Refactor/engine redesign#21

Merged
atterpac merged 13 commits into
mainfrom
refactor/engine-redesign
May 30, 2026
Merged

Refactor/engine redesign#21
atterpac merged 13 commits into
mainfrom
refactor/engine-redesign

Conversation

@atterpac
Copy link
Copy Markdown
Owner

Refactor of the engine/process internals behind the existing config API, plus bug fixes,
runtime logging controls, consolidated examples, and test coverage (engine+process now
~91%).

Bug fixes

  • StringtoConfigTOML parsed TOML with the YAML decoder — now uses toml.Decode.
  • IgnoreGit was a no-op: .gitignore patterns were read into a map nothing consulted. Now
    actually applied in shouldIgnore.
  • slog.Error calls passed a bare error as a key, failing go vet and blocking go test.
  • NewEngineFromConfig installed no logger; TOML/YAML constructors mutated a throwaway
    config copy and discarded Slog.
  • CLI: unset comma flags produced [""] ignore lists; an unknown config extension left a
    nil engine → panic.
  • BackgroundStruct was never run — only its DelayNext was read.
  • Removed os.Exit(1) from library code.
  • Untracked ~11 MB of committed binaries.

Refactor

  • Replaced os.Chdir-based process running with per-command cmd.Dir, removing the
    global-cwd race with the watcher.
  • New supervisor lifecycle: Start / Reload / Shutdown with per-process contexts.
    Removed the Ctxs/Cancels side maps and the dead ctx.Done() calls.
  • Collapsed ~420 lines of duplicated per-OS process code into a setProcessGroup /
    killProcessTree / shellInvocation shim.
  • Real trailing-edge debounce (the last save in a burst wins).
  • Commands now run through a shell (sh -c / cmd /C), so quotes/pipes/&& work.
  • Deleted the dead ignoreMap machinery.

Behavior changes

  • BackgroundStruct.Cmd now runs as a long-lived background process: started once, survives
    reloads, killed at shutdown.
  • ExecList (CLI -e) now actually produces processes; REFRESH_EXEC marks the primary.

New

  • Runtime logging: SetLogLevel / DisableLogs / EnableLogs, plus SetLogger wrapping a
    custom logger.
  • Re-exported Execute, ExecuteType, type constants, and the KILL_STALE/REFRESH_EXEC
    markers from the engine package.

Removed

  • tui/ package and the root main.go (entrypoint is cmd/refresh); dropped the
    charmbracelet deps.
  • Deprecated NewEngine, AttachBackgroundCallback, and the unused BackgroundCallback
    field.
  • The old example/ module; consolidated into examples/basic and examples/kitchen-sink.

Tests

  • examples/kitchen-sink doubles as the end-to-end integration test: all execute types,
    ChangeDir, callback veto, ignore rules, BackgroundStruct, clean shutdown.
  • Unit tests for config parsing, ExecList conversion, debounce/watcher, logging, shell
    execution, failure paths, and CLI flag mapping.
  • CI now runs go vet + go test -race ./... on Go 1.25; bumped EOL action versions.

Notes

  • cmd.Dir change and the supervisor rewrite are the highest-risk parts; verified with
    -race and a live reload smoke test (no leaked processes).
  • Command parsing relies on the shell, so command strings are not portable between POSIX and
    Windows.

@atterpac atterpac merged commit 12aa19b into main May 30, 2026
8 checks passed
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