Skip to content

fix(tui): add null guard for ctx.sid in /reload-mcp slash command#17822

Closed
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/tui-reload-mcp-null-sid-guard
Closed

fix(tui): add null guard for ctx.sid in /reload-mcp slash command#17822
luyao618 wants to merge 1 commit into
NousResearch:mainfrom
luyao618:fix/tui-reload-mcp-null-sid-guard

Conversation

@luyao618

Copy link
Copy Markdown
Contributor

Summary

Add a null guard for ctx.sid in the /reload-mcp slash command handler, matching the existing pattern used by /rollback and /save.

Problem

When ctx.sid is null (no active session), /reload-mcp crashes because it passes null as session_id: string to the reload.mcp RPC call. The TypeScript type for params.session_id is string, but ctx.sid is string | null.

Fix

Added an early-return null check at the top of the run handler, before building the RPC params:

if (!ctx.sid) {
  return ctx.transcript.sys("/reload-mcp requires an active session")
}

This matches the guard pattern already used by /rollback (line 193) and /save in the same file.

Changed Files

  • ui-tui/src/app/slash/commands/ops.ts — 3 lines added

Closes #17794

When ctx.sid is null (no active session), /reload-mcp crashes because
it passes null as session_id to the gateway RPC call. Other mutating
slash commands (/rollback, /save) already have this guard.

Add the same early-return pattern: check ctx.sid before building the
RPC params, and show a user-friendly message instead of crashing.

Closes NousResearch#17794
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists labels Apr 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #17774 — same null-guard fix for /reload-mcp ctx.sid crash (#17794). PR #17821 also competes.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #17774 — same fix for #17773/#17794: null guard on ctx.sid in /reload-mcp.

@luyao618 luyao618 closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants