mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 15:31:27 +00:00
fix(cli): harden /btw command error handling and type safety
- Add null/undefined guard in formatBtwError to avoid "null"/"undefined" strings - Add type guard for btw property in HistoryItemDisplay to prevent crash - Extract isBtwCommand regex to module-level constant and simplify with [/?] Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
905f2c3f36
commit
13423f0676
3 changed files with 8 additions and 9 deletions
|
|
@ -62,19 +62,15 @@ export const isSlashCommand = (query: string): boolean => {
|
|||
return true;
|
||||
};
|
||||
|
||||
const BTW_COMMAND_RE = /^[/?]btw(?:\s|$)/;
|
||||
|
||||
/**
|
||||
* Checks if a query is a /btw side-question invocation.
|
||||
* Accepts both "/btw" and "?btw" prefixes.
|
||||
*/
|
||||
export const isBtwCommand = (query: string): boolean => {
|
||||
const trimmed = query.trim();
|
||||
if (!trimmed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const normalized = trimmed.startsWith('?') ? `/${trimmed.slice(1)}` : trimmed;
|
||||
|
||||
return /^\/btw(?:\s|$)/.test(normalized);
|
||||
return trimmed.length > 0 && BTW_COMMAND_RE.test(trimmed);
|
||||
};
|
||||
|
||||
const debugLogger = createDebugLogger('COMMAND_UTILS');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue