mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-08-23 07:15:39 +00:00
* base : slash-command/misc foundation - model icon and focus-selector constants * feat : slash-command picker and command parsing helpers * refactor : wire command and @-mention pickers into the chat form * ui : improve model selector keyboard navigation and load/dismiss * feat: Unify markdown/raw-text rendering under one setting with migration * fix: Misc fixes - tool-call subtitle, assistant wrap, progress guards * feat: Clamp and style numeric settings inputs from registry bounds
31 lines
959 B
TypeScript
31 lines
959 B
TypeScript
/**
|
|
* Slash-command token detection for the chat form. Valid only at offset 0.
|
|
*/
|
|
export function findCommandToken(
|
|
value: string
|
|
): { name: string; args: string; end: number } | null {
|
|
if (!value.startsWith('/')) return null;
|
|
|
|
const rest = value.slice(1);
|
|
const spaceIdx = rest.search(/\s/);
|
|
const name = spaceIdx === -1 ? rest : rest.slice(0, spaceIdx);
|
|
const args = spaceIdx === -1 ? '' : rest.slice(spaceIdx + 1);
|
|
|
|
return { name, args, end: value.length };
|
|
}
|
|
|
|
/**
|
|
* Stable signature of a slash-command token for use as a "dismissed"
|
|
* marker: while the picker is closed and this exact token is still intact,
|
|
* the picker does not re-open on in-token edits.
|
|
*/
|
|
export interface CommandDismissSnapshot {
|
|
name: string;
|
|
args: string;
|
|
}
|
|
|
|
export function takeCommandDismissSnapshot(value: string): CommandDismissSnapshot | null {
|
|
const token = findCommandToken(value);
|
|
if (!token) return null;
|
|
return { name: token.name, args: token.args };
|
|
}
|