Skip to content

feat(server): add t3 wake command to send a message to an existing thread - #6

Merged
Fryuni merged 3 commits into
mainfrom
t3code/add-cli-wake-thread-command
Sep 13, 2026
Merged

Fryuni merged 3 commits into
mainfrom
t3code/add-cli-wake-thread-command

Conversation

@Fryuni

@Fryuni Fryuni commented Sep 13, 2026

Copy link
Copy Markdown
Owner

What Changed

Adds a t3 wake <thread-id> <message> CLI command that sends a message to an existing thread and requests a turn through the running server, without minting new state or touching the persisted thread. Discovery of a running server (state file lookup, pid liveness, well-known descriptor probe) was extracted from t3 pair into a shared cli/runningServer.ts module, and wake reuses it.

The command:

  • Validates the message (non-empty, within PROVIDER_SEND_TURN_MAX_INPUT_CHARS) before touching any server state.
  • Discovers the running server via the shared discovery logic, with the same worktree/T3CODE_HOME precedence as t3 pair.
  • Issues a short-lived session with orchestration read/operate scopes, snapshots the thread, then dispatches a thread.turn.start carrying the message and the thread's current runtime and interaction modes, revoking the session afterwards.
  • Fails with clear errors when no server is running, the thread is missing or deleted, or delivery cannot be confirmed.

Also: agent subprocesses now receive T3CODE_THREAD_ID in their environment across all providers (Codex, Claude, Cursor, Grok, OpenCode, Antigravity, OhMyPi), so spawned agent tooling can identify the thread it is driving.

Why

Waking an existing thread currently requires the web/mobile client. A CLI entry point lets scripts and other agents push a follow-up message into a thread from the terminal or automation, which pairs naturally with the new T3CODE_THREAD_ID environment variable — an agent running inside a thread can wake another thread (or be woken) without human intervention.

Extracting server discovery from pair.ts keeps pair unchanged behaviorally while giving wake (and future commands) one correct implementation of "find the running server," including the stale-state and port-reuse guards.

UI Changes

Not applicable — CLI only.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

- Sends a message to a running server or desktop app and requests a turn, using the thread's existing provider, model, and modes
- Extracts shared running-server discovery from t3 pair into cli/runningServer.ts
- Never starts a server; fails cleanly when none is running
- Set the thread ID env var across Claude, Codex, Cursor, Grok, OpenCode, OhMyPi, and Antigravity sessions, including Codex shell tools and ACP child commands
- Document the variable and its limits in docs/user/composer.md
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-13T20:17:00.204436Z 1fe94d4 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 7a05cb11d3

ℹ️ 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 apps/server/src/cli/wake.ts
@Fryuni

Fryuni commented Sep 13, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 1fe94d43cf

ℹ️ 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".

@Fryuni
Fryuni merged commit 2cbf55e into main Sep 13, 2026
@Fryuni
Fryuni deleted the t3code/add-cli-wake-thread-command branch September 13, 2026 20:17
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