Remove /browse since we have better support

This commit is contained in:
Enrico Ros
2025-01-14 09:06:26 -08:00
parent 2a29ccdcf5
commit 26733d6fea
8 changed files with 12 additions and 45 deletions
-16
View File
@@ -1,16 +0,0 @@
import LanguageIcon from '@mui/icons-material/Language';
import type { ICommandsProvider } from './ICommandsProvider';
export const CommandsBrowse: ICommandsProvider = {
id: 'cmd-ass-browse',
rank: 20,
getCommands: () => [{
primary: '/browse',
arguments: ['URL'],
description: 'Assistant will download the web page',
Icon: LanguageIcon,
}],
};
+2 -4
View File
@@ -1,13 +1,12 @@
import { ChatCommand, ICommandsProvider } from './ICommandsProvider';
import type { ChatCommand, ICommandsProvider } from './ICommandsProvider';
import { CommandsAlter } from './CommandsAlter';
import { CommandsBrowse } from './CommandsBrowse';
import { CommandsDraw } from './CommandsDraw';
import { CommandsHelp } from './CommandsHelp';
import { CommandsReact } from './CommandsReact';
export type CommandsProviderId = 'cmd-ass-browse' | 'cmd-ass-t2i' | 'cmd-chat-alter' | 'cmd-help' | 'cmd-mode-react';
export type CommandsProviderId = 'cmd-ass-t2i' | 'cmd-chat-alter' | 'cmd-help' | 'cmd-mode-react';
type TextCommandPiece =
| { type: 'nocmd'; value: string; }
@@ -15,7 +14,6 @@ type TextCommandPiece =
const ChatCommandsProviders: Record<CommandsProviderId, ICommandsProvider> = {
'cmd-ass-browse': CommandsBrowse,
'cmd-ass-t2i': CommandsDraw,
'cmd-chat-alter': CommandsAlter,
'cmd-help': CommandsHelp,
@@ -685,13 +685,12 @@ export function Composer(props: {
!llmAttachmentDraftsCollection.canAttachAllFragments ? 'warning'
: undefined;
// stable randomization of the /verb, between '/draw', '/react', '/browse'
// stable randomization of the /verb, between '/draw', '/react'
const placeholderAction = React.useMemo(() => {
const actions: string[] = ['/react'];
if (props.capabilityHasT2I) actions.push('/draw');
if (hasComposerBrowseCapability) actions.push('/browse');
return actions[Math.floor(Math.random() * actions.length)];
}, [hasComposerBrowseCapability, props.capabilityHasT2I]);
}, [props.capabilityHasT2I]);
let textPlaceholder: string =
isDraw ? 'Describe what you would like to see...'
@@ -4,7 +4,6 @@ import { ConversationHandler } from '~/common/chat-overlay/ConversationHandler';
import { createTextContentFragment, DMessageFragment, isTextContentFragment } from '~/common/stores/chat/chat.fragments';
import { extractChatCommand, helpPrettyChatCommands } from '../commands/commands.registry';
import { runBrowseGetPageUpdatingState } from './browse-load';
import { runImageGenerationUpdatingState } from './image-generate';
import { runReActUpdatingState } from './react-tangent';
@@ -34,9 +33,6 @@ export async function _handleExecuteCommand(lastMessageId: DMessageId, lastMessa
// Valid /commands are intercepted here, and override chat modes, generally for mechanics or sidebars
switch (providerId) {
case 'cmd-ass-browse':
return await runBrowseGetPageUpdatingState(cHandler, userText);
case 'cmd-ass-t2i':
return await runImageGenerationUpdatingState(cHandler, userText);
+5 -1
View File
@@ -1,3 +1,6 @@
/*
// NOTE: this is not used anymore and here just as a reference code and to demonstrate alternative conversation modes / editors
import { callBrowseFetchPageOrThrow } from '~/modules/browse/browse.client';
import type { ConversationHandler } from '~/common/chat-overlay/ConversationHandler';
@@ -36,4 +39,5 @@ export const runBrowseGetPageUpdatingState = async (cHandler: ConversationHandle
return false;
}
};
};
*/
-1
View File
@@ -65,7 +65,6 @@ export interface CapabilityBrowsing {
isServerConfig: boolean;
isClientConfig: boolean;
isClientValid: boolean;
inCommand: boolean;
inComposer: boolean;
inReact: boolean;
inPersonas: boolean;
+2 -8
View File
@@ -20,17 +20,16 @@ const _styleHelperText = {
export function BrowseSettings() {
// external state
const { mayWork, isServerConfig, isClientValid, inCommand, inComposer, inReact, inPersonas } = useBrowseCapability();
const { mayWork, isServerConfig, isClientValid, inComposer, inReact, inPersonas } = useBrowseCapability();
const {
wssEndpoint, setWssEndpoint,
pageTransform, setPageTransform,
setEnableCommandBrowse, setEnableComposerAttach, setEnableReactTool, setEnablePersonaTool,
setEnableComposerAttach, setEnableReactTool, setEnablePersonaTool,
} = useBrowseStore(useShallow(state => ({
wssEndpoint: state.wssEndpoint,
pageTransform: state.pageTransform,
setPageTransform: state.setPageTransform,
setWssEndpoint: state.setWssEndpoint,
setEnableCommandBrowse: state.setEnableCommandBrowse,
setEnableComposerAttach: state.setEnableComposerAttach,
setEnableReactTool: state.setEnableReactTool,
setEnablePersonaTool: state.setEnablePersonaTool,
@@ -80,11 +79,6 @@ export function BrowseSettings() {
<FormHelperText sx={_styleHelperText}>{platformAwareKeystrokes('Load and attach when pasting a URL')}</FormHelperText>
</FormControl>
<FormControl disabled={!mayWork}>
<Checkbox size='sm' label='/browse' checked={inCommand} onChange={(event) => setEnableCommandBrowse(event.target.checked)} />
<FormHelperText sx={_styleHelperText}>{platformAwareKeystrokes('Use /browse to load a web page')}</FormHelperText>
</FormControl>
<FormControl disabled={!mayWork}>
<Checkbox size='sm' label='ReAct' checked={inReact} onChange={(event) => setEnableReactTool(event.target.checked)} />
<FormHelperText sx={_styleHelperText}>Enables loadURL() in ReAct</FormHelperText>
+1 -8
View File
@@ -15,9 +15,6 @@ interface BrowseState {
pageTransform: BrowsePageTransform;
setPageTransform: (transform: BrowsePageTransform) => void;
enableCommandBrowse: boolean;
setEnableCommandBrowse: (value: boolean) => void;
enableComposerAttach: boolean;
setEnableComposerAttach: (value: boolean) => void;
@@ -39,9 +36,6 @@ export const useBrowseStore = create<BrowseState>()(
pageTransform: 'text',
setPageTransform: (pageTransform: BrowsePageTransform) => set(() => ({ pageTransform })),
enableCommandBrowse: true,
setEnableCommandBrowse: (enableCommandBrowse: boolean) => set(() => ({ enableCommandBrowse })),
enableComposerAttach: true,
setEnableComposerAttach: (enableComposerAttach: boolean) => set(() => ({ enableComposerAttach })),
@@ -64,7 +58,7 @@ export function useBrowseCapability(): CapabilityBrowsing {
const isServerConfig = getBackendCapabilities().hasBrowsing;
// external client state
const { wssEndpoint, enableCommandBrowse, enableComposerAttach, enableReactTool, enablePersonaTool } = useBrowseStore();
const { wssEndpoint, enableComposerAttach, enableReactTool, enablePersonaTool } = useBrowseStore();
// derived state
const isClientConfig = !!wssEndpoint;
@@ -76,7 +70,6 @@ export function useBrowseCapability(): CapabilityBrowsing {
isServerConfig,
isClientConfig,
isClientValid,
inCommand: mayWork && enableCommandBrowse,
inComposer: mayWork && enableComposerAttach,
inReact: mayWork && enableReactTool,
inPersonas: mayWork && enablePersonaTool,