Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix(cowork): highlight recognized skill commands
thinhlpg861304ee14b5
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsxindex 2e88cd20e..491c7009c 100644--- a/web-app/src/containers/ChatInput.tsx+++ b/web-app/src/containers/ChatInput.tsx@@ -155,6 +155,7 @@ type ChatInputProps = {* across surfaces.*/tokenSource?: TokenUsageSource+ highlightedPrefix?: string | null}// Video containers llama-server can decode via ffmpeg/ffprobe into frames.@@ -187,8 +188,10 @@ const ChatInput = memo(function ChatInput({ownsToolSet = true,surfaceControls,tokenSource,+ highlightedPrefix,}: ChatInputProps) {const textareaRef = useRef<HTMLTextAreaElement>(null)+ const highlightRef = useRef<HTMLDivElement>(null)const [isFocused, setIsFocused] = useState(false)const [rows, setRows] = useState(1)const serviceHub = useServiceHub()@@ -2101,6 +2104,18 @@ const ChatInput = memo(function ChatInput({))}</div>)}+ <div className="relative">+ {highlightedPrefix && prompt.startsWith(highlightedPrefix) && (+ <div+ ref={highlightRef}+ aria-hidden="true"+ className={cn('pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words px-4 pt-4 text-transparent', className)}+ style={{ overflowWrap: 'break-word' }}+ >+ <mark className="rounded-sm bg-primary/20 text-transparent">{highlightedPrefix}</mark>+ {prompt.slice(highlightedPrefix.length)}+ </div>+ )}<TextareaAutosizedir="auto"ref={textareaRef}@@ -2109,6 +2124,12 @@ const ChatInput = memo(function ChatInput({maxRows={10}value={prompt}data-testid={'chat-input'}+ onScroll={(event) => {+ if (highlightRef.current) {+ highlightRef.current.scrollTop = event.currentTarget.scrollTop+ highlightRef.current.scrollLeft = event.currentTarget.scrollLeft+ }+ }}onChange={(e) => {const value = e.target.valueconst cursorIdx = e.target.selectionStart@@ -2192,6 +2213,7 @@ const ChatInput = memo(function ChatInput({className)}/>+ </div>{/* @path file reference picker popover */}{filePickerOpen && effectiveAgentMode && (<div className="relative">diff --git a/web-app/src/lib/__tests__/skillCommands.test.ts b/web-app/src/lib/__tests__/skillCommands.test.tsindex 2131770f8..9572452f2 100644--- a/web-app/src/lib/__tests__/skillCommands.test.ts+++ b/web-app/src/lib/__tests__/skillCommands.test.ts@@ -3,6 +3,7 @@ import {filterSkillCommands,parseSkillCommand,resolveSkillCommand,+ skillCommandPrefix,} from '@/lib/skillCommands'describe('skill slash commands', () => {@@ -42,3 +43,17 @@ describe('skill slash commands', () => {expect(resolveSkillCommand(skills, { name: 'missing', args: '', explicit: true })).toBeNull()})})++describe('skill command highlighting', () => {+ const skills = [{ name: 'code-review', description: 'Review code', user_invocable: true }]++ it('returns only the recognized command prefix', () => {+ expect(skillCommandPrefix('/code-review hi hi', skills)).toBe('/code-review')+ expect(skillCommandPrefix('/code-review', skills)).toBe('/code-review')+ })++ it('does not highlight unknown or embedded command-like text', () => {+ expect(skillCommandPrefix('/missing hello', skills)).toBeNull()+ expect(skillCommandPrefix('please /code-review', skills)).toBeNull()+ })+})diff --git a/web-app/src/lib/skillCommands.ts b/web-app/src/lib/skillCommands.tsindex 16ff33a17..eb3b6e5b4 100644--- a/web-app/src/lib/skillCommands.ts+++ b/web-app/src/lib/skillCommands.ts@@ -46,3 +46,14 @@ export function resolveSkillCommand(})return matches.length === 1 ? matches[0] : null}++export function skillCommandPrefix(+ text: string,+ skills: SkillCommandMeta[]+): string | null {+ const match = text.match(/^\/(?:skill:)?([^\s/]+)/)+ if (!match) return null+ const parsed = parseSkillCommand(text)+ if (!parsed || !resolveSkillCommand(skills, parsed)) return null+ return match[0]+}diff --git a/web-app/src/routes/cowork.tsx b/web-app/src/routes/cowork.tsxindex 69fb6026a..827cde8d3 100644--- a/web-app/src/routes/cowork.tsx+++ b/web-app/src/routes/cowork.tsx@@ -135,6 +135,7 @@ import {filterSkillCommands,parseSkillCommand,resolveSkillCommand,+ skillCommandPrefix,} from '@/lib/skillCommands'export const Route = createFileRoute(route.cowork as any)({@@ -1470,6 +1471,7 @@ function CoworkPage() {initialMessage={true}scopeKey={session?.id}ownsToolSet={false}+ highlightedPrefix={skillCommandPrefix(prompt, skillCommands)}onSubmit={handleSubmit}onStop={handleStop}chatStatus={running ? 'streaming' : 'ready'}