File tree Expand file tree Collapse file tree
plugin/plugins/study_companion/surfaces Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export async function callPlugin<T = JsonObject>(
4747 entryId : string ,
4848 args : JsonObject = { } ,
4949 signal ?: AbortSignal ,
50+ timeoutMs = POLL_TIMEOUT_MS ,
5051) : Promise < T > {
5152 const created = await readJsonResponse < RunCreated > ( await fetch ( '/runs' , {
5253 method : 'POST' ,
@@ -58,7 +59,7 @@ export async function callPlugin<T = JsonObject>(
5859 if ( ! runId ) {
5960 throw new Error ( 'Run id missing' ) ;
6061 }
61- const deadline = Date . now ( ) + POLL_TIMEOUT_MS ;
62+ const deadline = Date . now ( ) + Math . max ( timeoutMs , POLL_INTERVAL_MS ) ;
6263 while ( Date . now ( ) < deadline ) {
6364 await waitForPoll ( signal ) ;
6465 const run = await readJsonResponse < RunStatus > ( await fetch ( `/runs/${ runId } ` , { signal } ) , 'Run poll' ) ;
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ type NoteSavePayload = {
1111 note ?: NoteItem ;
1212} ;
1313
14+ const AI_EXPAND_POLL_TIMEOUT_MS = 90000 ;
15+
1416type NoteDraftSnapshot = {
1517 noteId : string ;
1618 notebookId : string ;
@@ -149,11 +151,16 @@ export default function NoteEditor(props: PluginSurfaceProps) {
149151 setBusy ( true ) ;
150152 setStatus ( text ( props , 'ui.notebook.ai_working' , 'AI working...' ) ) ;
151153 try {
152- const payload = await callPlugin < { content ?: string } > ( 'study_note_ai_expand' , {
153- note_id : noteId ,
154- content,
155- topic_context : topics ,
156- } ) ;
154+ const payload = await callPlugin < { content ?: string } > (
155+ 'study_note_ai_expand' ,
156+ {
157+ note_id : noteId ,
158+ content,
159+ topic_context : topics ,
160+ } ,
161+ undefined ,
162+ AI_EXPAND_POLL_TIMEOUT_MS ,
163+ ) ;
157164 if ( payload . content ) {
158165 setContent ( payload . content ) ;
159166 }
You can’t perform that action at this time.
0 commit comments