feat(tui): add local embedded TUI mode with terminal/chat aliases#66767
Conversation
Greptile SummaryThis PR adds a gateway-free embedded TUI mode ( The implementation is well-structured: the Confidence Score: 5/5Safe to merge — no P0/P1 issues found; all comments are style-level suggestions. The core concurrency correctness (finalSent guard, abort-on-stop, run-map cleanup) is solid and well-tested (145 tests). The Commander alias fix is correct. The prior P1 concern about broad process.argv scanning has been addressed. Remaining comments are P2 (an unused required field in a context type, and a type assertion in listModels that could expose undefined names). src/tui/embedded-backend.ts (listModels type assertion) and src/tui/tui-command-handlers.ts (noteLocalRunId required but unused). Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/tui/tui-command-handlers.ts
Line: 29-53
Comment:
**`noteLocalRunId` required in context but never used**
`noteLocalRunId` is declared as a required field in `CommandHandlerContext` (no `?`) but is never destructured or referenced anywhere inside `createCommandHandlers`. The actual `noteLocalRunId` call happens in `createEventHandlers` via the `handleChatEvent` / `pendingOptimisticUserMessage` path — the command-handler context doesn't need it. Keeping it required silently forces callers to supply a value that is immediately discarded, and may mislead future readers into thinking it is used here.
```suggestion
noteLocalRunId?: (runId: string) => void;
noteLocalBtwRunId?: (runId: string) => void;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/tui/embedded-backend.ts
Line: 346-355
Comment:
**Unchecked type assertion on catalog entries**
`allowedCatalog` and `catalog` are cast to `TuiModelChoice[]` without verifying the shape. `TuiModelChoice` requires `name: string` (non-optional), but the catalog entries from `loadGatewayModelCatalog` / `buildAllowedModelSet` may use `name?: string | undefined`. If any entry is missing `name`, callers that unconditionally read `model.name` (e.g. the model-selector label) will render `undefined`.
Consider using a mapping to ensure the shape, mirroring what `GatewayChatClient.listModels` returns from the wire:
```typescript
const entries = allowedCatalog.length > 0 ? allowedCatalog : catalog;
return entries.map((m) => ({
id: m.id,
name: m.name ?? m.id,
provider: m.provider,
contextWindow: m.contextWindow,
reasoning: m.reasoning,
}));
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "TUI: fix alias detection, cross-platform..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43a2fc94c1
ℹ️ 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".
|
@greptileai review again please |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fdda81c21
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fcadc8f60
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff005edb26
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d682cbf3a6
ℹ️ 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".
|
Also addressed the two summary-only review notes in 5af25f2957:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5af25f2957
ℹ️ 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".
|
Also fixed the current CI failures in 5993a99d9b:
Local verification on this branch now passes:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5993a99d9b
ℹ️ 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".
|
Merged the latest |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1cf689c6eb
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9acb355b0
ℹ️ 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".
458f2af to
74d4d28
Compare
obviyus
left a comment
There was a problem hiding this comment.
Verified the embedded local TUI approval path: approval-required plugin tools no longer get auto-approved when the Gateway approval route is unavailable, and the local TUI smoke runs without a Gateway.
Maintainer follow-up: restored embedded session resolution, added the Unreleased changelog entry, and fixed setup TUI relaunch so local: true becomes --local in the spawned process.
Local gate: targeted embedded/TUI/wizard tests, pnpm check, and pnpm build.
|
Landed on main. Thanks @fuller-stack-dev. |
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
…ck-dev) * feat(tui): add local embedded TUI mode with terminal/chat aliases Adds a gateway-free local TUI path so users can run openclaw in their terminal without needing a running gateway process. - TuiBackend interface abstraction (tui-backend.ts) with EmbeddedTuiBackend implementation that drives the agent loop in-process - openclaw tui --local flag for local embedded mode - openclaw terminal / openclaw chat aliases that imply --local - /auth slash command with codex CLI delegation to avoid prolite plan issue - Default model display fallback on startup - Local-aware status text and log suppression - Concise auth error hints, raw HTML 403 suppression - Onboarding hatch flow launches local TUI (no gateway required) - Commander alias bug fix in run-main.ts (.aliases() check) - All new and updated tests passing (145/145) * TUI: fix alias detection, cross-platform codex lookup, and history byte-budget safeguards * TUI: remove RuntimeEnv type annotation to fix CI oxlint error * TUI: filter gateway-dependent tools and auto-approve plugin hooks in embedded mode * TUI: suppress console noise and add embedded mode system prompt note * TUI: reduce embedded-mode tool filtering from 15 to 7, add local session tools * TUI: fix remaining PR review comments * TUI: address latest review feedback and CI drift * Core: align prompt helper with latest base * Core: match prompt helper formatting with base * Core: restore prompt helper from latest base * fix(tui): preserve local auth fallback in source checkouts * fix(tts): guard telephony provider invocation * fix(tui): support Windows codex auth shim * fix(tui): harden local auth flow * fix: preserve embedded tool-first run events * fix(tui): keep embedded plugin approvals gated * fix(tui): restore embedded attempt import * fix(tui): resolve sessions in embedded stub * fix: add embedded TUI changelog entry (openclaw#66767) (thanks @fuller-stack-dev) * fix: pass setup TUI local mode through relaunch (openclaw#66767) (thanks @fuller-stack-dev) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
Adds a gateway-free local TUI path so users can run OpenClaw in their terminal without needing a running gateway process.
openclaw tui --localflag for local embedded mode (no gateway required)openclaw terminal/openclaw chataliases that imply--localTuiBackendinterface abstraction (tui-backend.ts) withEmbeddedTuiBackendimplementation driving the agent loop in-process viaagentCommandFromIngress/authslash command with TUI suspend/resume flow andcodex logindelegation for OpenAI Codex provider (avoids prolite plan issue from OpenClaw's OAuth originator).alias()bug fix inrun-main.ts(.aliases().includes()check)Files Changed
tui-backend.ts,embedded-backend.tstui.ts,tui-types.ts,commands.tstui-command-handlers.ts,tui-event-handlers.ts,tui-session-actions.tstui-cli.ts,run-main.ts,register.subclis-core.ts,subcli-descriptors.tsmodel-selection-display.ts,pi-embedded-subscribe.handlers.lifecycle.tssetup.finalize.tsgateway-chat.tsTuiBackend, shared types extractedTesting
pnpm buildcleanpnpm check(lint/format/cycles/tsgo) clean on touched files