Skip to content

Add dashboard headless worker mode (CLI flag + worker loop + adapter spawn) - #5

Merged
Kothulhu94 merged 1 commit into
masterfrom
codex/add-headless-mode-for-dashboard-commands
Jun 1, 2026
Merged

Add dashboard headless worker mode (CLI flag + worker loop + adapter spawn)#5
Kothulhu94 merged 1 commit into
masterfrom
codex/add-headless-mode-for-dashboard-commands

Conversation

@Kothulhu94

Copy link
Copy Markdown
Owner

Motivation

  • Provide a dedicated headless mode for the dashboard to run the agent loop via stdin/stdout without launching the interactive TUI.
  • Make the Control Room spawn a deterministic worker subprocess instead of relying on the legacy LAUNCHED_BY_DASHBOARD environment handoff.

Description

  • Add --dashboard-worker (alias --headless-worker) to src/cli/args_parser.js and document it in the help text.
  • Implement a lightweight dashboard worker loop in bin/smallcode.js (runDashboardWorker) that accepts plain lines or JSON-lines, extracts a command/prompt, calls runAgentLoop(input, config), captures output, and emits lifecycle markers such as [HARNESS] ready, [user] ..., [assistant] ..., [IPC] Run Complete, and [IPC] Error: ... to stdout.
  • Hook the worker into startup before the normal TUI path by checking flags.dashboardWorker in main() and suppressing some human-facing output in worker mode.
  • Update src/controlroom/harness_adapter.js:startTUI() to spawn node bin/smallcode.js --dashboard-worker and remove the LAUNCHED_BY_DASHBOARD env dependency.
  • Add focused unit tests test/cli_args_parser.test.js and test/controlroom_harness_adapter.test.js to validate argument parsing and spawn behavior.

Testing

  • Ran node --check bin/smallcode.js to ensure file parses without syntax errors, and it succeeded.
  • Ran unit tests with node --test test/cli_args_parser.test.js test/controlroom_harness_adapter.test.js, and both tests passed.
  • Ran node test/e2e_offline.js which failed in this environment due to a missing installed dependency (chalk) unrelated to the new worker logic; the failure prevented the full offline smoke checks but does not affect the new worker/unit tests.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68096b52dd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/smallcode.js
Comment on lines +2137 to +2139
const payload = JSON.parse(line);
if (payload && typeof payload === 'object') {
return String(payload.command ?? payload.input ?? payload.prompt ?? payload.text ?? '').trim();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve raw JSON prompts without envelope fields

When the dashboard sends a plain prompt that happens to be a JSON object, this branch parses it as a worker envelope and replaces it with only command/input/prompt/text. For inputs like {"scripts":{"test":"node --test"}} none of those fields exist, so this returns an empty string and runOne silently ignores the user request; objects containing a text or command property are also unintentionally truncated. Since sendCommand() writes raw user text, treat parsed JSON as an envelope only when one of the supported fields is actually present, otherwise fall back to the original line.

Useful? React with 👍 / 👎.

@Kothulhu94
Kothulhu94 merged commit 75596cb into master Jun 1, 2026
@Kothulhu94
Kothulhu94 deleted the codex/add-headless-mode-for-dashboard-commands branch June 1, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant