Skip to content

Trim the semantic Command constructor's name, description and category [patch] - #186

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/semantic-command-normalization
Oct 18, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/semantic-command-normalization

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #146

What changed

Command(CommandId, CommandName, CommandDescription?, CommandCategory?) trimmed only the id (#123). A padded category was stored as given, so GetCommandsByCategory, which trims its input, never found the command until a save and reload. The constructor now normalizes the same way the string constructor does. Both constructors use one TrimToNull helper:

  • name, description and category are trimmed
  • a whitespace-only description or category becomes null
  • a whitespace-only name throws ArgumentException, which is what both constructors' docs already say

Tests

  • New SemanticCommandNormalizationTests: padded values are trimmed, blank values become null, a blank name throws, the result matches the string constructor's, and GetCommandsByCategory("Editing") finds the command without a reload.
  • With the fix reverted, all 5 new tests fail. With it, the full suite passes (211/211).

Generated by Claude Code

…y [patch]

The semantic-type constructor trimmed only the id, so a padded category was
stored as given and GetCommandsByCategory, which trims its input, never found
it until a save and reload. It now normalizes the same way the string
constructor does: name, description and category are trimmed, a blank
description or category becomes null, and a blank name is refused.

Fixes #146

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCikcgWw27K5y1T5jxpzcG
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 2d035ce into main Oct 18, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/semantic-command-normalization branch October 18, 2026 10:54
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.

Command built from semantic types keeps padded name/description/category, so GetCommandsByCategory misses it until a save/reload

2 participants