From ad25dbf3ec75db7ecf601e3e48b5ef36a657582f Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Mon, 27 Apr 2026 17:05:43 +0530 Subject: [PATCH] fix: restore post-create table ai suggestions --- .../database-[database]/+layout.svelte | 19 +++++++++++++++++ .../database-[database]/subNavigation.svelte | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte index 8a647bbe6..e3459c229 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/+layout.svelte @@ -11,6 +11,7 @@ import { tablesSearcher } from '$lib/commandCenter/searchers'; import { Dependencies } from '$lib/constants'; import { showCreateEntity, randomDataModalState, resetSampleFieldsConfig } from './store'; + import { entityColumnSuggestions } from './(suggestions)/store'; import { TablesPanel } from '$lib/commandCenter/panels'; import { canWriteTables, canWriteDatabases } from '$lib/stores/roles'; import { showCreateBackup, showCreatePolicy } from './backups/store'; @@ -25,6 +26,7 @@ import type { Snippet } from 'svelte'; import { Input as SuggestionsInput } from '$database/(suggestions)/index'; import { Modal } from '$lib/components'; + import { subNavigation } from '$lib/stores/database'; let { children @@ -42,6 +44,7 @@ $registerSearchers(tablesSearcher); async function createEntity(entityId: string, name: string, dimension?: number) { + const shouldSuggestColumns = $entityColumnSuggestions.enabled; const entity = await databaseSdk.createEntity({ databaseId, entityId, @@ -50,6 +53,7 @@ }); await invalidate(Dependencies.DATABASE); + await invalidate(Dependencies.TABLES); await goto( withPath( resolveRoute( @@ -60,6 +64,21 @@ ) ); + subNavigation.update(); + + if (shouldSuggestColumns) { + entityColumnSuggestions.update((store) => ({ + ...store, + enabled: true, + thinking: true, + force: true, + entity: { + id: entity.$id, + name: entity.name + } + })); + } + } $effect(() => { diff --git a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/subNavigation.svelte b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/subNavigation.svelte index 011dc9a88..b9b0b192e 100644 --- a/src/routes/(console)/project-[region]-[project]/databases/database-[database]/subNavigation.svelte +++ b/src/routes/(console)/project-[region]-[project]/databases/database-[database]/subNavigation.svelte @@ -27,6 +27,7 @@ import { Query } from '@appwrite.io/console'; import { onMount } from 'svelte'; import { subNavigation } from '$lib/stores/database'; + import { sleep } from '$lib/helpers/promises'; import { type Entity, type EntityList, @@ -83,6 +84,26 @@ databaseId: page.params.database, queries: [Query.orderDesc(''), Query.limit(100)] }); + + const currentEntityId = page.params[entityTypeSingular]; + + if ( + currentEntityId && + !entities.entities.some((entity: Entity) => entity.$id === currentEntityId) + ) { + for (let attempt = 0; attempt < 3; attempt++) { + await sleep(250); + + entities = await databaseSdk.listEntities({ + databaseId: page.params.database, + queries: [Query.orderDesc(''), Query.limit(100)] + }); + + if (entities.entities.some((entity: Entity) => entity.$id === currentEntityId)) { + break; + } + } + } } finally { loading = false; }