Files
llama.cpp/tools/ui/tests/client/components/ChatFormPickersHarness.svelte
T
Pascal 18f7ad7fc9 server, ui: only offer a working directory when a tool reads it (#26762)
The working directory chip showed up as soon as the server exposed any
builtin tool, so a server started with just get_datetime, or a user who
turned every filesystem tool off in the settings, still got a control
that nothing would read.

Tools now declare whether they resolve their paths and run against the
working directory, next to the write permission they already publish in
the /tools listing. The WebUI shows the chip and enables the /cwd
command only when at least one such tool is both served and left
enabled.
2026-08-08 16:36:21 +02:00

52 lines
1.1 KiB
Svelte

<script lang="ts">
import {
useChatFormPickers,
type UseChatFormPickersReturn
} from '$lib/hooks/use-chat-form-pickers.svelte';
let value = $state('');
let caretOffset = $state(0);
const calls: string[] = [];
const pickers = useChatFormPickers({
getValue: () => value,
setValue: (v) => {
value = v;
calls.push(`setValue:${v}`);
},
getCaretOffset: () => caretOffset,
setCaretOffset: (o) => {
caretOffset = o;
},
focusInput: () => {},
getShowModelSelector: () => true,
hasPrompts: () => true,
hasCwdTools: () => true,
getCwd: () => null,
getServerHome: () => null,
openModelSelector: () => {
calls.push('openModelSelector');
},
getPickersRef: () => undefined
});
// Simulate the user typing: update the buffer and run the input flow.
export function type(text: string) {
value = text;
caretOffset = text.length;
pickers.handleInput();
}
export function getValue() {
return value;
}
export function getCalls() {
return calls;
}
export function getPickers(): UseChatFormPickersReturn {
return pickers;
}
</script>