mirror of
https://github.com/open-webui/computer.git
synced 2026-11-24 22:37:40 -05:00
refac
This commit is contained in:
1 parent
36bf4e60af
commit
c536fe6e52
2 files changed
+25
-7
No files matched your search
@@ -72,6 +72,7 @@
|
||||
contextUsage?: ContextUsage | null;
|
||||
tasks?: ChatTask[];
|
||||
queuedMessages?: { id: string; content: string }[];
|
||||
hasChatContent?: boolean;
|
||||
onsend: () => void;
|
||||
oncompact?: () => void;
|
||||
onplan?: () => void;
|
||||
@@ -92,6 +93,7 @@
|
||||
contextUsage = null,
|
||||
tasks = [],
|
||||
queuedMessages = [],
|
||||
hasChatContent = false,
|
||||
onsend,
|
||||
oncompact,
|
||||
onplan,
|
||||
@@ -930,16 +932,22 @@
|
||||
const slashCommandIds = $derived.by(() => {
|
||||
if (!slashCommandQuery.startsWith('/')) return [];
|
||||
const ids: string[] = [];
|
||||
if (oncompact && '/compact'.startsWith(slashCommandQuery)) ids.push('compact');
|
||||
if (hasChatContent && oncompact && '/compact'.startsWith(slashCommandQuery))
|
||||
ids.push('compact');
|
||||
if (onplan && '/plan'.startsWith(slashCommandQuery)) ids.push('plan');
|
||||
if (onstatus && '/status'.startsWith(slashCommandQuery)) ids.push('status');
|
||||
if (hasChatContent && onstatus && '/status'.startsWith(slashCommandQuery)) ids.push('status');
|
||||
if (
|
||||
hasChatContent &&
|
||||
onskillslist &&
|
||||
slashCommandQuery !== '/skills:list' &&
|
||||
'/skills:list'.startsWith(slashCommandQuery)
|
||||
)
|
||||
ids.push('skills:list');
|
||||
if (slashCommandQuery !== '/skills:create' && '/skills:create'.startsWith(slashCommandQuery))
|
||||
if (
|
||||
hasChatContent &&
|
||||
slashCommandQuery !== '/skills:create' &&
|
||||
'/skills:create'.startsWith(slashCommandQuery)
|
||||
)
|
||||
ids.push('skills:create');
|
||||
return ids;
|
||||
});
|
||||
|
||||
@@ -296,6 +296,11 @@
|
||||
|
||||
const streaming = $derived(allMessages.some((m) => m.role === 'assistant' && !m.done));
|
||||
const isLanding = $derived(allMessages.length === 0 && !chatId);
|
||||
const hasChatContent = $derived(
|
||||
activePath.some(
|
||||
({ msg }) => msg.role === 'user' && msg.content.trim() && !msg.content.trim().startsWith('/')
|
||||
)
|
||||
);
|
||||
const workspaceDisplayName = $derived(getPathDisplayName(workspace, 'workspace'));
|
||||
const displayChatTitle = $derived(chatTitle || firstUserMessageTitle() || workspaceDisplayName);
|
||||
const runningCommandSessions = $derived(commandSessions.filter((session) => !session.done));
|
||||
@@ -715,7 +720,11 @@
|
||||
let text = inputText.trim();
|
||||
if (!text || !selectedModel) return;
|
||||
if (sending) return;
|
||||
if (text === '/compact') {
|
||||
if (!hasChatContent && text.startsWith('/') && text !== '/plan') {
|
||||
toast.error('Only /plan is available before this chat has content');
|
||||
return;
|
||||
}
|
||||
if (hasChatContent && text === '/compact') {
|
||||
await handleManualCompact();
|
||||
return;
|
||||
}
|
||||
@@ -724,12 +733,12 @@
|
||||
inputText = '';
|
||||
return;
|
||||
}
|
||||
if (text === '/status') {
|
||||
if (hasChatContent && text === '/status') {
|
||||
handleStatusCommand();
|
||||
inputText = '';
|
||||
return;
|
||||
}
|
||||
if (text === '/skills:list') {
|
||||
if (hasChatContent && text === '/skills:list') {
|
||||
await handleSkillsListCommand();
|
||||
inputText = '';
|
||||
return;
|
||||
@@ -1522,7 +1531,7 @@
|
||||
placeholder={$t('chat.placeholder', { name: workspaceDisplayName })}
|
||||
tasks={chatTasks}
|
||||
onsend={send}
|
||||
onstatus={handleStatusCommand}
|
||||
onplan={handlePlanCommand}
|
||||
{queuedMessages}
|
||||
onqueuesendnow={handleQueueSendNow}
|
||||
onqueueedit={handleQueueEdit}
|
||||
@@ -1632,6 +1641,7 @@
|
||||
{streaming}
|
||||
{workspace}
|
||||
{contextUsage}
|
||||
{hasChatContent}
|
||||
tasks={chatTasks}
|
||||
onsend={send}
|
||||
oncompact={handleManualCompact}
|
||||
|
||||
Reference in new issue
Block a user