Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,32 @@ jobs:
with:
version: v2.12.2

# Linux builds its own platform files (systemd, notify-send, the desktop
# dialogs), so it gets its own build, test and lint run.
build-test-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.26"
check-latest: true

- name: Vet
run: go vet ./...

- name: Build
run: go build ./...

- name: Test (race)
run: go test ./... -race

- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.12.2

web:
runs-on: ubuntu-latest
defaults:
Expand Down
2 changes: 2 additions & 0 deletions PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Status: draft for review · No implementation until explicitly commissioned.
Based on: `anforderungskatalog-taskqueue.md` (v0.2) + clarification dialogue (decisions D1–D8 below).

The Linux port is planned and tracked separately in [docs/linux/PLAN.md](docs/linux/PLAN.md). The macOS plan below remains unchanged.

---

## 1. Summary
Expand Down
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ workflow engine:
- [How it works](#how-it-works)
- [Install](#install)
- [Coming from ClaudeQ](#coming-from-claudeq)
- [Linux (preview)](#linux-preview)
- [Using it](#using-it)
- [The app](#the-app)
- [Settings](#settings)
Expand Down Expand Up @@ -250,6 +251,32 @@ the notification permission (macOS asks again) and the window's view
preferences such as the artifact grid or list layout. Appearance and accent
colour are stored by the daemon and do carry over.

## Linux (preview)

The daemon, the CLI and the dashboard also run on Linux. There is no window app
and no package yet: build from source and open the dashboard in a browser. The
plan and the state of the port are in [docs/linux/PLAN.md](docs/linux/PLAN.md).

```sh
scripts/build-web.sh
go build -o ~/.local/bin/ ./cmd/dispatchqd ./cmd/dispatchq
dispatchqd install # systemd user service: starts at login, restarts on exit
xdg-open http://127.0.0.1:10765
```

What is different on Linux:

| Feature | On Linux |
|---|---|
| Autostart | A systemd user service, `~/.config/systemd/user/dispatchq.service`. It runs while you are logged in. |
| Data | `~/.local/share/dispatchq` (`$XDG_DATA_HOME/dispatchq`). `DISPATCHQ_HOME` still overrides it. |
| Sleep during a run | Held off with a logind lock (`systemd-inhibit`), as `caffeinate` does on macOS. |
| Wake from sleep | Not available. Linux needs root to set a wake alarm, so timed tasks wait until the computer is awake. |
| Desktop notifications | Through `notify-send`. Pushover, ntfy and webhooks work as on macOS. |
| Folder and save dialogs | `kdialog` on KDE Plasma, `zenity` elsewhere. Without either, type the path. |
| Continue in a terminal | `xdg-terminal-exec`, else the desktop's terminal (Konsole, GNOME Terminal) or `x-terminal-emulator`. |
| Updates and uninstall | Not from the app. Build a new version from source. To remove DispatchQ, run `dispatchqd uninstall` and delete the binaries. |

## Using it

1. **Ask DispatchQ** (**⌘J**) and describe the job in plain words; the assistant
Expand Down Expand Up @@ -2003,8 +2030,9 @@ that.

## Data on disk

Everything lives under `~/Library/Application Support/dispatchq` (override with the
`DISPATCHQ_HOME` environment variable):
Everything lives under `~/Library/Application Support/dispatchq` (on Linux
`~/.local/share/dispatchq`; override with the `DISPATCHQ_HOME` environment
variable):

| Path | Contents |
|------|----------|
Expand All @@ -2021,7 +2049,8 @@ Everything lives under `~/Library/Application Support/dispatchq` (override with
| `.lock` / `.daemon.lock` | Lock files, both empty of interest. `.lock` serializes config/state writes between the daemon and a `dispatchq` command; `.daemon.lock` holds the running daemon's pid and is what makes a second daemon on the same store refuse to start. Both are released when the holding process exits, so neither needs clearing by hand. |

The LaunchAgent itself is at
`~/Library/LaunchAgents/de.maierdaniel.dispatchq.plist`.
`~/Library/LaunchAgents/de.maierdaniel.dispatchq.plist` (on Linux the systemd
user service is at `~/.config/systemd/user/dispatchq.service`).

## Uninstall

Expand Down Expand Up @@ -2104,7 +2133,7 @@ verification notes are in [PLAN.md](PLAN.md).

## Requirements

- macOS 12 or newer
- macOS 12 or newer, or Linux with systemd as a [preview](#linux-preview)
- The [Claude Code](https://claude.com/claude-code) CLI, installed and
authenticated
- Optionally the [Codex](https://learn.chatgpt.com/docs/developer-commands?surface=cli)
Expand Down
18 changes: 14 additions & 4 deletions cmd/dispatchq/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/danielmaier42/claudeq/internal/provider/adapters"
"github.com/danielmaier42/claudeq/internal/randid"
"github.com/danielmaier42/claudeq/internal/store"
"github.com/danielmaier42/claudeq/internal/system"
"github.com/danielmaier42/claudeq/internal/task"
"github.com/danielmaier42/claudeq/internal/version"
)
Expand Down Expand Up @@ -721,16 +722,25 @@ func cmdMove(st *store.Store, args []string) error {
return cmdList(st, nil)
}

// newRunNowEngine is the engine of a manual run. It gets the platform's sleep
// inhibitor like the daemon's engine, so a long `dispatchq run-now` is not
// frozen by idle sleep when the user walks away.
func newRunNowEngine(st *store.Store, c clock.Clock, queueBin string) *engine.Engine {
registry := adapters.Default()
eng := engine.New(st, limit.NewGates(c), &executor.Executor{
Registry: registry, Home: st.Home(), QueueBin: queueBin,
}, c, provider.NewChecker(registry))
eng.SetSleepInhibitor(system.DefaultSleepInhibitor())
return eng
}

func cmdRunNow(st *store.Store, id string) error {
c := clock.Real{}
// Give the manual run the same self-queue context the daemon provides, so a
// task tested with run-now can queue follow-up work too. This process is the
// dispatchq CLI, so its own path is the queue binary.
self, _ := os.Executable()
registry := adapters.Default()
eng := engine.New(st, limit.NewGates(c), &executor.Executor{
Registry: registry, Home: st.Home(), QueueBin: self,
}, c, provider.NewChecker(registry))
eng := newRunNowEngine(st, c, self)
fmt.Printf("running task %q now...\n", id)
started := c.Now()
if err := eng.RunTaskNow(context.Background(), id); err != nil {
Expand Down
25 changes: 25 additions & 0 deletions cmd/dispatchq/runnow_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"testing"

"github.com/danielmaier42/claudeq/internal/clock"
"github.com/danielmaier42/claudeq/internal/store"
"github.com/danielmaier42/claudeq/internal/system"
)

// `dispatchq run-now` builds its own engine, separate from the daemon's. It must
// get the platform's sleep inhibitor too, or a long manual run is frozen when
// the machine idles to sleep while the user is away.
func TestRunNowEngineHoldsOffSleepLikeTheDaemon(t *testing.T) {
st, err := store.Open(t.TempDir())
if err != nil {
t.Fatalf("store.Open: %v", err)
}
eng := newRunNowEngine(st, clock.Real{}, "dispatchq")
want := system.DefaultSleepInhibitor()
got := eng.SleepInhibitor()
if (want != nil) != (got != nil) {
t.Fatalf("run-now engine inhibitor set = %t, platform offers one = %t", got != nil, want != nil)
}
}
15 changes: 15 additions & 0 deletions cmd/dispatchq/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os/exec"
"os/user"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
Expand All @@ -35,6 +36,9 @@ type uninstallEnv struct {
}

func cmdUninstall(args []string) error {
if err := uninstallSupported(runtime.GOOS); err != nil {
return err
}
exe, err := os.Executable()
if err != nil {
return fmt.Errorf("locate executable: %w", err)
Expand All @@ -55,6 +59,17 @@ func cmdUninstall(args []string) error {
})
}

// uninstallSupported reports why `dispatchq uninstall` cannot run on goos. It
// runs the macOS uninstaller package. Elsewhere it names the manual steps.
func uninstallSupported(goos string) error {
if goos == "darwin" {
return nil
}
return fmt.Errorf("dispatchq uninstall removes the macOS app and is not available on %s. "+
"Run `dispatchqd uninstall` to remove the login service, then delete the dispatchq binaries "+
"(and, to remove tasks and history too, the data directory)", goos)
}

// runUninstall runs the uninstaller package with the command-line installer,
// the same package the app's Uninstall button opens in the Installer window.
func runUninstall(args []string, env uninstallEnv) error {
Expand Down
10 changes: 10 additions & 0 deletions cmd/dispatchq/uninstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,13 @@ func TestUninstallDoesNotCreateDataDir(t *testing.T) {
t.Fatalf("data directory was created (stat err = %v)", err)
}
}

func TestUninstallSupportedOnlyOnMacOS(t *testing.T) {
if err := uninstallSupported("darwin"); err != nil {
t.Fatalf("darwin: %v", err)
}
err := uninstallSupported("linux")
if err == nil || !strings.Contains(err.Error(), "dispatchqd uninstall") {
t.Fatalf("linux: err = %v, want a pointer to dispatchqd uninstall", err)
}
}
2 changes: 2 additions & 0 deletions cmd/dispatchqapp/main_other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//go:build !darwin

// Command dispatchqapp is the native DispatchQ window. On systems without a
// window implementation it exits with a message.
package main

import (
Expand Down
Loading