Skip to content

fix: stop auto sample data generation on table create#3007

Merged
HarshMN2345 merged 5 commits intomainfrom
fix-ai-table-creation-flow
Apr 27, 2026
Merged

fix: stop auto sample data generation on table create#3007
HarshMN2345 merged 5 commits intomainfrom
fix-ai-table-creation-flow

Conversation

@HarshMN2345
Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR fixes the bug where auto sample data generation was triggered immediately on table creation. The root cause was an onMount in input.svelte that unconditionally set entityColumnSuggestions.enabled = true on cloud, causing the random-data modal to fire after every table create. The fix removes that auto-enable, threads a typed SubNavigationEvent through the navigation trigger for optimistic sidebar updates, and defers the AI column-suggestions state update until after navigation completes.

Confidence Score: 5/5

Safe to merge; only P2 findings present.

All findings are P2 style/type-safety suggestions. The core logic — removing auto-enable, optimistic sidebar update, deferred suggestions state — is correct and the navigation ordering is sound.

subNavigation.svelte — minor type cast for the optimistically inserted entity.

Important Files Changed

Filename Overview
src/lib/stores/database.ts Adds typed SubNavigationEvent discriminated union so the sub-navigation trigger can carry entity-creation payloads; subscriber/update signatures updated accordingly.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(entity)/views/create.svelte Adds createdEntity flag so resetSampleFieldsConfig is skipped only on successful creation with suggestions enabled; guards $effect with !creatingEntity to prevent premature entity reset.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/input.svelte Removes the onMount that auto-set $entityColumnSuggestions.enabled = true on cloud; this is the core fix stopping automatic sample-data generation on table create.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte Captures shouldSuggestColumns before creation, adds invalidate(Dependencies.TABLES), replaces the immediate random-data modal trigger with a subNavigation event + deferred entityColumnSuggestions update for post-navigation AI column suggestions.
src/routes/(console)/project-[region]-[project]/databases/database-[database]/subNavigation.svelte Optimistically inserts the new entity into the sidebar list on entity-created events, avoiding a redundant loadEntities() round-trip; minor type-cast concern for the partial entity object.

Reviews (4): Last reviewed commit: "format" | Re-trigger Greptile

@HarshMN2345 HarshMN2345 merged commit 95f1f2e into main Apr 27, 2026
4 checks passed
@HarshMN2345 HarshMN2345 deleted the fix-ai-table-creation-flow branch April 27, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants