[codex] Fix notebook SDK race after createLocal#198
Conversation
Signed-off-by: Jeremy lewi <jeremy@lewi.us>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b67323014
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const NOTEBOOK_OPEN_RESOLVE_TIMEOUT_MS = 1500 | ||
| const NOTEBOOK_OPEN_RESOLVE_POLL_MS = 10 |
There was a problem hiding this comment.
Remove fixed 1.5s notebook-open deadline
waitForOpenedNotebook now fails after a hard-coded 1500ms even when openNotebook succeeded, which can make notebooks.createLocal(...), drive.saveAsCurrentNotebook(...), and app.openNotebook(...) throw spuriously on slower devices, large notebooks, or background-tab timer throttling. In this flow, notebook materialization is asynchronous (CurrentDoc change → context effect → model creation), so a strict 1.5s cap introduces a new user-visible failure mode where the notebook opens eventually but the helper rejects.
Useful? React with 👍 / 👎.
Signed-off-by: Jeremy lewi <jeremy@lewi.us>
|
I think we need to rethink this but I forgot exactly how; I think there was a bigger refactor of the SDK we potentially needed to do. |
Summary
Root cause
notebooks.createLocal()opened the new notebook and immediately callednotebooks.get({ uri }). In the app runtime, opening a notebook only updatescurrentDocfirst, whileNotebookContextcreates theNotebookDatamodel later in an effect. That left a short window whereresolveNotebook(uri)returnednull, causingNo notebook found for the requested target.even though creation and saving had already succeeded.Impact
await notebooks.createLocal("...")now returns reliably in App Console / appkernel flowsValidation
pnpm -C app exec vitest run src/lib/notebookData.test.tsrunme run build --project /Users/jlewi/git_runmeweb --ignore-pattern .worktreesrunme run test --project /Users/jlewi/git_runmeweb --ignore-pattern .worktrees