Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions src/newtab/stores/providerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const ProviderSchema = z.object({

export type Provider = z.infer<typeof ProviderSchema>

const CHAT_PROVIDER_READY_TIMEOUT_MS = 8000
const CHAT_PROVIDER_POST_LOAD_DELAY_MS = 400
const CHAT_PROVIDER_READY_TIMEOUT_MS = 3000
const CHAT_PROVIDER_POST_LOAD_DELAY_MS = 200

const DEFAULT_PROVIDERS: Provider[] = [
{
Expand All @@ -41,38 +41,29 @@ const DEFAULT_PROVIDERS: Provider[] = [
name: 'ChatGPT',
category: 'llm',
actionType: 'url',
urlPattern: 'https://chatgpt.com',
urlPattern: 'https://chatgpt.com/?q=%s',
available: true,
openIn: 'newTab',
autoSubmit: true,
submitKey: 'Enter',
focusBeforeSubmit: true,
iconUrl: '/assets/new_tab_search/openai.svg'
},
{
id: 'claude',
name: 'Claude',
category: 'llm',
actionType: 'url',
urlPattern: 'https://claude.ai/new',
urlPattern: 'https://claude.ai/new?q=%s',
available: true,
openIn: 'newTab',
autoSubmit: true,
submitKey: 'Enter',
focusBeforeSubmit: true,
iconUrl: '/assets/new_tab_search/claude.svg'
},
{
id: 'google',
name: 'Google',
category: 'search',
actionType: 'url',
urlPattern: 'https://www.google.com',
urlPattern: 'https://www.google.com/search?q=%s',
available: true,
openIn: 'newTab',
autoSubmit: true,
submitKey: 'Enter',
focusBeforeSubmit: true,
iconUrl: '/assets/new_tab_search/google.svg'
}
]
Expand Down Expand Up @@ -564,7 +555,7 @@ export const useProviderStore = create<ProviderState & ProviderActions>()(
}
}

const needsDomWork = Boolean(tabId != null && (!hasPlaceholder || provider.autoSubmit))
const needsDomWork = Boolean(tabId != null && !hasPlaceholder)
let queryInjected = false

if (needsDomWork && tabId != null) {
Expand Down Expand Up @@ -599,8 +590,8 @@ export const useProviderStore = create<ProviderState & ProviderActions>()(
queryInjected = await injectQuery();

if (!queryInjected) {
for (let attempt = 0; attempt < 5 && !queryInjected; attempt++) {
await new Promise(resolve => setTimeout(resolve, 400));
for (let attempt = 0; attempt < 2 && !queryInjected; attempt++) {
await new Promise(resolve => setTimeout(resolve, 200));
queryInjected = await injectQuery();
}
}
Expand Down