Skip to content

Commit c4f0e1a

Browse files
committed
fix(study): extend notebook AI expand polling
1 parent ee815da commit c4f0e1a

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

plugin/plugins/study_companion/surfaces/memory_shared.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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');

plugin/plugins/study_companion/surfaces/note_editor.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type NoteSavePayload = {
1111
note?: NoteItem;
1212
};
1313

14+
const AI_EXPAND_POLL_TIMEOUT_MS = 90000;
15+
1416
type 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
}

0 commit comments

Comments
 (0)