feat(grist): open and create grist documents as drive files#3942
Conversation
Dispatch `.grist` files (a real io.cozy.files carrying the Grist doc id in `metadata.externalId`) to the `grist` coquille, mirroring the Docs integration: `computeFileType` returns `grist`, `computeApp` maps it to the `grist` slug and `computePath` builds `/bridge/grist/<externalId>`. Add a flag-gated "Grist" entry to the create menu that points to the coquille's `/bridge/grist/new/<folderId>` route. Behind the `drive.grist.enabled` flag.
WalkthroughA new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Our agent can fix these. Install it.
Gates Passed
3 Quality Gates Passed
Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/modules/navigation/hooks/helpers.ts`:
- Around line 201-202: In the 'grist' case within the switch statement, the
externalId from the file metadata is being directly interpolated into the bridge
path without proper URL encoding. Fix this by wrapping the metadata.externalId
access with encodeURIComponent to ensure reserved or special characters are
properly escaped before being inserted into the path string in the return
statement.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dc8ea3b4-c5c8-43e8-ab18-8477283ece02
⛔ Files ignored due to path filters (1)
src/assets/icons/icon-grist.svgis excluded by!**/*.svg
📒 Files selected for processing (6)
src/locales/en.jsonsrc/locales/fr.jsonsrc/modules/drive/Toolbar/components/CreateDocumentItems.jsxsrc/modules/drive/Toolbar/components/CreateGristItem.jsxsrc/modules/grist/helpers.jssrc/modules/navigation/hooks/helpers.ts
| case 'grist': | ||
| return `/bridge/grist/${(file as IOCozyFile).metadata.externalId}` |
There was a problem hiding this comment.
Encode externalId before inserting it into the bridge path.
Line 202 interpolates raw metadata.externalId; reserved characters can break routing. Use encodeURIComponent here.
Suggested patch
case 'grist':
- return `/bridge/grist/${(file as IOCozyFile).metadata.externalId}`
+ return `/bridge/grist/${encodeURIComponent(
+ (file as IOCozyFile).metadata.externalId
+ )}`📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| case 'grist': | |
| return `/bridge/grist/${(file as IOCozyFile).metadata.externalId}` | |
| case 'grist': | |
| return `/bridge/grist/${encodeURIComponent( | |
| (file as IOCozyFile).metadata.externalId | |
| )}` |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/modules/navigation/hooks/helpers.ts` around lines 201 - 202, In the
'grist' case within the switch statement, the externalId from the file metadata
is being directly interpolated into the bridge path without proper URL encoding.
Fix this by wrapping the metadata.externalId access with encodeURIComponent to
ensure reserved or special characters are properly escaped before being inserted
into the path string in the return statement.
BundleMonUnchanged files (20)
Total files change -5B 0% Groups updated (1)
Unchanged groups (2)
Final result: ✅ View report in BundleMon website ➡️ |
Summary
.gristfiles (realio.cozy.fileswith the Grist doc id inmetadata.externalId) to thegristcoquille, mirroring the Docs integration:computeFileTypereturnsgrist,computeAppmaps it to thegristslug,computePathbuilds/bridge/grist/<externalId>.drive.grist.enabledflag-gated "Grist" entry to the create menu, pointing to the coquille's/bridge/grist/new/<folderId>route.isGristhelper, theicon-grist.svgasset and themenu_create_gristlabel.Summary by CodeRabbit
Release Notes