fix(tui): guard /reload-mcp against null ctx.sid#17821
Open
0xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(tui): guard /reload-mcp against null ctx.sid#178210xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
0xDevNinja wants to merge 1 commit intoNousResearch:mainfrom
Conversation
`/reload-mcp` typed `params.session_id: string` but `ctx.sid` is `string | null`, so triggering the command before a session was active crashed the TUI. Apply the same null-guard pattern that `/rollback` already uses: if `ctx.sid` is null, surface a sys message and skip the RPC entirely. Updated `createSlashHandler.test.ts`: - removed the row that asserted `reload.mcp` is called with `session_id: null` (that was the bug) - added a positive test (active session → RPC invoked with sid) - added a regression test (no session → sys message, no RPC) Fixes NousResearch#17794
Collaborator
Collaborator
Contributor
Author
|
@alt-glitch Thanks for flagging — I checked all three.
Happy to defer to whichever the maintainer prefers — but #17774's approach doesn't match the typed |
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
/reload-mcpdeclaredparams.session_id: stringbut read it directly fromctx.sid, which is typed asstring | null. Triggering the command before a session was active crashed the TUI. Mirrors the null-guard pattern that/rollback(and/save) already use — surface a sys message instead of hitting the RPC with a null id.Related Issue
Fixes #17794
Type of Change
Changes Made
ui-tui/src/app/slash/commands/ops.ts— early-return withctx.transcript.sys('/reload-mcp requires an active session')whenctx.sidis null, before constructingparams.ui-tui/src/__tests__/createSlashHandler.test.ts:reload.mcpis called withsession_id: null(that was the bug — the typedstringfield was getting null).How to Test
cd ui-tui && npm installnpm run build --prefix packages/hermes-inknpx vitest run createSlashHandler— 45 / 45 pass, including the two new cases.npx vitest run) — 539 / 539.npm run type-check— clean.Checklist
Code
Documentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/A