Skip to content

Commit 06178ca

Browse files
authored
Merge pull request #162 fix(newtab): eliminate 8-10s lag in search providers
fix(newtab): eliminate 8-10s lag in search providers
2 parents ed75ba9 + 6226c42 commit 06178ca

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/newtab/stores/providerStore.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export const ProviderSchema = z.object({
2424

2525
export type Provider = z.infer<typeof ProviderSchema>
2626

27-
const CHAT_PROVIDER_READY_TIMEOUT_MS = 8000
28-
const CHAT_PROVIDER_POST_LOAD_DELAY_MS = 400
27+
const CHAT_PROVIDER_READY_TIMEOUT_MS = 3000
28+
const CHAT_PROVIDER_POST_LOAD_DELAY_MS = 200
2929

3030
const DEFAULT_PROVIDERS: Provider[] = [
3131
{
@@ -41,38 +41,29 @@ const DEFAULT_PROVIDERS: Provider[] = [
4141
name: 'ChatGPT',
4242
category: 'llm',
4343
actionType: 'url',
44-
urlPattern: 'https://chatgpt.com',
44+
urlPattern: 'https://chatgpt.com/?q=%s',
4545
available: true,
4646
openIn: 'newTab',
47-
autoSubmit: true,
48-
submitKey: 'Enter',
49-
focusBeforeSubmit: true,
5047
iconUrl: '/assets/new_tab_search/openai.svg'
5148
},
5249
{
5350
id: 'claude',
5451
name: 'Claude',
5552
category: 'llm',
5653
actionType: 'url',
57-
urlPattern: 'https://claude.ai/new',
54+
urlPattern: 'https://claude.ai/new?q=%s',
5855
available: true,
5956
openIn: 'newTab',
60-
autoSubmit: true,
61-
submitKey: 'Enter',
62-
focusBeforeSubmit: true,
6357
iconUrl: '/assets/new_tab_search/claude.svg'
6458
},
6559
{
6660
id: 'google',
6761
name: 'Google',
6862
category: 'search',
6963
actionType: 'url',
70-
urlPattern: 'https://www.google.com',
64+
urlPattern: 'https://www.google.com/search?q=%s',
7165
available: true,
7266
openIn: 'newTab',
73-
autoSubmit: true,
74-
submitKey: 'Enter',
75-
focusBeforeSubmit: true,
7667
iconUrl: '/assets/new_tab_search/google.svg'
7768
}
7869
]
@@ -564,7 +555,7 @@ export const useProviderStore = create<ProviderState & ProviderActions>()(
564555
}
565556
}
566557

567-
const needsDomWork = Boolean(tabId != null && (!hasPlaceholder || provider.autoSubmit))
558+
const needsDomWork = Boolean(tabId != null && !hasPlaceholder)
568559
let queryInjected = false
569560

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

601592
if (!queryInjected) {
602-
for (let attempt = 0; attempt < 5 && !queryInjected; attempt++) {
603-
await new Promise(resolve => setTimeout(resolve, 400));
593+
for (let attempt = 0; attempt < 2 && !queryInjected; attempt++) {
594+
await new Promise(resolve => setTimeout(resolve, 200));
604595
queryInjected = await injectQuery();
605596
}
606597
}

0 commit comments

Comments
 (0)