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:
wenshao 2026-03-22 01:21:07 +08:00
parent 905f2c3f36
commit 13423f0676
3 changed files with 8 additions and 9 deletions

View file

@ -227,7 +227,9 @@ const HistoryItemDisplayComponent: React.FC<HistoryItemDisplayProps> = ({
{itemForDisplay.type === 'insight_progress' && (
<InsightProgressMessage progress={itemForDisplay.progress} />
)}
{itemForDisplay.type === 'btw' && <BtwMessage btw={itemForDisplay.btw} />}
{itemForDisplay.type === 'btw' && itemForDisplay.btw && (
<BtwMessage btw={itemForDisplay.btw} />
)}
</Box>
);
};