Skip to content

fix: remove -i flag from SSH login shell to prevent remote chat errors#40

Merged
Keith-CY merged 2 commits intomainfrom
fix/ssh-interactive-shell-error
Mar 2, 2026
Merged

fix: remove -i flag from SSH login shell to prevent remote chat errors#40
Keith-CY merged 2 commits intomainfrom
fix/ssh-interactive-shell-error

Conversation

@dev01lay2
Copy link
Copy Markdown
Collaborator

Problem

Remote chat via SSH fails with:

bash: cannot set terminal process group: Inappropriate ioctl for device
bash: no job control in this shell

This causes 操作 'unknown' 在 'remote_ssh' 环境执行失败 in the Chat panel.

Root Cause

wrap_login_shell_eval() in clawpal-core/src/shell.rs used bash -ilc (interactive + login). The -i flag triggers job control setup (set -o monitor) which requires a TTY. SSH exec channels don't have a TTY, so bash emits warnings to stderr and exits with code 1 on strict configurations.

Fix

  1. shell.rs: Changed -ilc-lc (login only). This still loads .bash_profile/.zprofile for PATH setup without requiring a terminal.

  2. agent.rs: remote_chat_via_openclaw now tries to extract JSON from stdout before checking exit code. This makes it resilient to cases where stderr warnings cause non-zero exit but the command actually succeeded.

  3. use-api.ts: Added missing "chatViaOpenclaw" method name to dispatch() call so error messages show the actual operation instead of 'unknown'.

Copy link
Copy Markdown

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

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: b0f6d49234

ℹ️ 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 on lines +96 to +97
pub fn get_session_usage_stats(session_id: String) -> Result<ZeroclawUsageStatsResponse, String> {
let stats = crate::runtime::zeroclaw::process::get_session_usage(&session_id);
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 Record per-session usage before exposing session stats

get_session_usage_stats now serves data from the new per-session map, but there is no call site that writes to that map during request execution (the only writer is record_session_usage, which is introduced but never invoked), so this endpoint always returns zeroed stats. In practice the new TokenBadge path never renders because totalTokens stays 0, making the session usage/cost feature non-functional.

Useful? React with 👍 / 👎.

Comment on lines +39 to +42
const handleSelect = async (model: string) => {
try {
await invoke("set_session_model_override", { sessionId, model });
setOverride(model);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Apply session model override when running zeroclaw

This UI persists a “session model override”, but the runtime model-selection path still reads only the global preference (load_zeroclaw_model_preference in run_zeroclaw_message) and never reads the new per-session override store, so selecting a model here does not change which model is actually used. That creates a misleading control where users think they switched models for a session but requests continue on the previous model.

Useful? React with 👍 / 👎.

Root cause: wrap_login_shell_eval() used bash -ilc (interactive+login).
The -i flag triggers job control setup which fails without a TTY on SSH
exec channels, producing 'cannot set terminal process group' errors.

Changes:
- shell.rs: use -lc (login only) instead of -ilc
- agent.rs: try extracting JSON from stdout before checking exit code,
  making remote chat resilient to stderr-only warnings
- use-api.ts: add missing method name to chatViaOpenclaw dispatch so
  error messages show actual operation instead of 'unknown'
@dev01lay2 dev01lay2 force-pushed the fix/ssh-interactive-shell-error branch from 42dc8be to c763a72 Compare March 2, 2026 09:12
Copy link
Copy Markdown
Collaborator

@Keith-CY Keith-CY left a comment

Choose a reason for hiding this comment

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

LGTM. Fix is scoped and consistent with the reported SSH non-TTY failure: uses login shell without -i for bash/zsh, preserves JSON parsing on stderr-warning non-zero exits, and includes the missing API operation name for error context. I didn’t identify blocking issues.

@Keith-CY Keith-CY merged commit b724b8a into main Mar 2, 2026
2 checks passed
@Keith-CY Keith-CY deleted the fix/ssh-interactive-shell-error branch March 5, 2026 08:36
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.

2 participants