Repository navigation
feat(cloud): store the Deepnote API token in .env and resolve it for Deepnote Cloud features - #563
Draft
Conversation
…Deepnote Cloud features Adds "Deepnote: Set API Token" and "Deepnote: Clear API Token", which keep DEEPNOTE_TOKEN in the nearest .env that already assigns it, else in the .env at the sync root or workspace folder root. Set checks the token against the Deepnote API first and offers to add .env to .gitignore when git does not ignore it. IDeepnoteApiTokenService returns the token that applies to a local file or folder and prompts for one when none is set. showCloudError reports failed Deepnote Cloud calls and offers to set a new token when Deepnote answers 401. Both commands and the service are disabled in untrusted workspaces; the commands are also disabled in the web extension host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Got2L1hwAr7GBzdxTequW8
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## tomaskislan/blu-6517-add-deepnotecloud-sync-and-align-the-bundled-deepnote #563 +/- ##
===========================================================================================================
Coverage 38% 38%
===========================================================================================================
Files 822 825 +3
Lines 41098 41325 +227
Branches 9044 9101 +57
===========================================================================================================
+ Hits 15620 15888 +268
+ Misses 23405 23353 -52
- Partials 2073 2084 +11
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@coderabbitai ignore
Summary
Adds "Deepnote: Set API Token" and "Deepnote: Clear API Token", and a desktop-only
IDeepnoteApiTokenServicethat the upcoming sync and publishing features will use to get a token.GET /v2/me, then writesDEEPNOTE_TOKEN=<token>to the nearest.envon the lookup path that already assigns it, else to the.envat the sync root or workspace folder root. When the built-in Git extension says git does not ignore that.env, a modal offers to add it to.gitignore.DEEPNOTE_TOKENassignment from the.envfiles on the lookup path. It never deletes a file.IDeepnoteApiTokenServicehasgetToken(uri)(no prompt) andgetOrPromptToken(uri)(runs the Set flow when no token is found).showCloudErrorreports failed Deepnote Cloud calls and, on a 401, offers "Set API Token" for the same file or folder.Closes #562
Stacked on #561 (
@deepnote/cloud-syncand the aligned@deepnote/*versions). The base branch is #561's branch so the diff shows only this change; retarget tomainonce #561 merges.Deviations from the issue
All deliberate, all covered by tests:
isSafeEnvEdit) also runs when the.envdoes not exist yet, so a token that would not read back as typed (for example one wrapped in backticks) is refused there too.fileworkspace folder (virtualWorkspacesistrueinpackage.json) is refused withlocalFilesOnlyinstead of being used as the fallback start..envor.gitignorethat cannot be read or written is reported withenvEditFailed(or logged for.gitignore) instead of rejecting the command. An error other than "file not found" while reading is never treated as "the file is empty".localFilesOnlyandopenFolderFirstare shown withshowErrorMessage..envthat is not valid UTF-8 is left untouched and named in an error; a UTF-8 byte order mark is kept. A non-UTF-8.gitignoregets its.envline appended without its other bytes changing.fetchquotes the wholeAuthorizationvalue in its error otherwise), so theapiTokenInvalidCharacterstext became "The token cannot contain spaces, quotes, # or control characters".](in the Deepnote workspace name is changed to] (in the confirmation, because notifications render[label](command:...)as runnable links.Known and left as the issue specifies: a
.envwith mixed LF and CRLF endings is rewritten with a single ending.Verification
Run on this branch (one commit on top of #561 at 7814e32):
npm run format,npm run lint(no errors),npm run typecheckandnpm run spell-checkpass.cloudErrors.node.unit.test.tsanddeepnoteApiTokenService.node.unit.test.ts. They use real temporary directories, including a symlinked.deepnote-sync.json.checkIgnoreguards inisIgnoredByGitare redundant with itscatch, and the case-insensitive comparison in the lookup loop only differs from the case-sensitive one on macOS and Windows.npm run compilesucceeds.dist/extension.node.jscontains the service;dist/extension.web.bundle.jscontains neither the service nor@deepnote/cloud-sync.opus-maxsubagents that ran thecode-review-typescriptskill, with one independent verifier per finding. Round one gave 16 findings (none P0 or P1); round two reviewed the fix commit and found one regression the first fixes had introduced, which is fixed. The findings that held up are the hardening in item 5 above plus extra tests.Not verified
process.platformin scratch runs, not on those systems.deepnote/deepnote) are not done.getWorkspaceis replaced by a stub in tests.deepnote.webExtensioncontext key is set at activation) was not checked at runtime.🤖 Generated with Claude Code
https://claude.ai/code/session_01Got2L1hwAr7GBzdxTequW8