Add: column waiting logic on suggestions as well#2663
Conversation
Console (appwrite/console)Project ID: Tip Every Git commit and branch gets its own deployment URL automatically |
WalkthroughThis PR introduces a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.ts (2)
29-33: RedundantclearTimeoutcall.
clearTimeout(timeout)is called on line 30, and thencleanup()on line 31 calls it again on line 40. While harmless, you could simplify by removing line 30 sincecleanup()already handles it.if (expectedCount > 0 && availableColumns.size >= expectedCount) { - clearTimeout(timeout); cleanup(); resolvePromise(); }
52-56: Same redundantclearTimeoutpattern.Similar to above, line 53 clears the timeout before
cleanup()is called, which also clears it.if (availableColumns.size >= expectedCount) { - clearTimeout(timeout); cleanup(); resolvePromise(); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.ts(1 hunks)src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte(7 hunks)src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte(3 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx,svelte}: Import reusable modules from the src/lib directory using the $lib alias
Use minimal comments in code; reserve comments for TODOs or complex logic explanations
Use $lib, $routes, and $themes aliases instead of relative paths for module imports
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.tssrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
**/*.ts: Define types inline or in .d.ts files, avoid creating separate .types.ts files
Use TypeScript in non-strict mode; any type is tolerated in this project
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.ts
**/*.{ts,tsx,js,jsx,svelte,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation, single quotes, 100 character line width, and no trailing commas per Prettier configuration
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.tssrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Configure dynamic routes using SvelteKit convention with [param] syntax in route directory names
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.tssrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
src/routes/**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Use SvelteKit file conventions: +page.svelte for components, +page.ts for data loaders, +layout.svelte for wrappers, +error.svelte for error handling, and dynamic route params in square brackets like [param]
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Use Svelte 5 + SvelteKit 2 syntax with TypeScript for component development
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
🧠 Learnings (4)
📚 Learning: 2025-09-25T04:21:57.071Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2373
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:536-552
Timestamp: 2025-09-25T04:21:57.071Z
Learning: In the Appwrite console database suggestions flow, after successfully creating columns via `createColumns()`, the `await invalidate(Dependencies.TABLE)` call causes the view to be destroyed and another view (populated table view) to be rendered, automatically cleaning up component state without needing manual reset.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.tssrc/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
📚 Learning: 2025-09-30T07:41:06.679Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2425
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:454-468
Timestamp: 2025-09-30T07:41:06.679Z
Learning: In `src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte`, the column suggestions API (console.suggestColumns) has a maximum limit of 7 columns returned, which aligns with the initial placeholder count of 7 in customColumns.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.sveltesrc/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
📚 Learning: 2025-11-03T13:26:21.384Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2540
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/indexes/+page.svelte:100-108
Timestamp: 2025-11-03T13:26:21.384Z
Learning: In the Appwrite console, the waterfall/fake data generation flow does not create indexes, only columns and data. Therefore, index realtime listeners do not need to be gated with `!$isWaterfallFromFaker` like column update listeners.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte
📚 Learning: 2025-10-07T14:17:11.597Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2413
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/terminology.ts:28-28
Timestamp: 2025-10-07T14:17:11.597Z
Learning: In src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/helpers/terminology.ts, the empty `vectordb: {}` entry in baseTerminology is intentional. The vectordb database type is not currently used because the backend API is not finalized, and no database type returns 'vectordb' at the moment.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte
🧬 Code graph analysis (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.ts (2)
src/lib/stores/sdk.ts (1)
RealtimeResponse(214-219)src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/store.ts (1)
Columns(9-21)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: e2e
🔇 Additional comments (4)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+layout.svelte (1)
292-317: Clean integration of the external column observer.The pattern of destructuring the observer's return values, assigning the handler, using
startWaiting/waitPromise, and cleaning up infinallyis well-structured. Thefinallyblock ensurescolumnCreationHandleris reset even if an error occurs, preventing stale handlers.src/routes/(console)/project-[region]-[project]/databases/database-[database]/(observer)/columnObserver.ts (1)
59-64: Consider thecleanupexport usage.The
cleanupfunction is exported but not called by current consumers. Both callers resetcolumnCreationHandler = nullin theirfinallyblocks but don't invokecleanup. This works because:
- If the promise resolves (success or timeout),
cleanupis called internally- Setting the handler to
nullprevents further event processingHowever, if a caller were to throw before
startWaitingis called, the timeout would never be set, so there's nothing to clean up. The current design is acceptable.src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte (2)
590-607: Good integration of real-time column observer.The
onMountcorrectly returns the realtime cleanup function, and the event filtering fordatabases.*.tables.*.columns.*is appropriate. CallingsuggestColumns()withoutawaitis intentional to allow the real-time subscription to start immediately, andsuggestColumnshas its own error handling internally.
979-1111: Consistent observer integration increateColumns.The pattern matches the implementation in
+layout.svelte:
- Initialize observer and assign handler before creating columns
- Call
startWaiting(count)after all creation requests complete- Await
waitPromisebefore invalidating and showing success notification- Reset handler in
finallyblockThis ensures columns are in
availablestatus before proceeding, fixing the race condition mentioned in the PR objectives.

What does this PR do?
Fixes the issue of error when generating sample data right after ai suggested columns are generated. The state mayb not always be available for columns, so we wait.
Test Plan
Manual.
Related PRs and Issues
N/A.
Have you read the Contributing Guidelines on issues?
Yes.
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.