Skip to content

Add Records: refetch-then-open when table is missing from the cached map #1492

Description

@dawsontoth

Follow-up from the review of #1471 (databases tab redesign). @kriszyp and @cb1kenobi suggested a friendlier alternative to the current stale-map toast for "Add Record(s)".

File

src/features/instance/databases/components/DatabaseActionModals.tsx

Current behavior

When the tree/overview right-click "Add New Record(s)" fires setWatchedValue('ShowAddTableRecords', { databaseName, tableName }) but the target table isn't in the fast describe_all map — a stale map between an external drop and the next refetch — the hub toasts "Couldn't open … it may have just been removed. Try refreshing." and clears the trigger. AddTableRowModal needs the table's schema (instanceTable), which today comes only from instanceDatabaseMap[db][table].

Proposed enhancement (refetch-then-open)

Instead of dead-ending on a transient miss:

  • On an add target missing from the map, first refetch (invalidate/refetch describe_all, or fetch describe_table for the target directly via getDescribeTableQueryOptions) and show a brief loading state.
  • If the table then resolves, open AddTableRowModal against it.
  • Only fall back to the "may have been removed" toast if it's still absent after the refetch (genuinely dropped).

Keep the fast path unchanged: when the table is in the map, open immediately with no extra fetch. Scope the change to the hub (and possibly sourcing instanceTable from a fresh describe_table when the map lacks it). Add a test if practical.

Low priority — reachable only in the brief window between an external drop and the cache refetch. Verify with npx vitest run src/features/instance/databases, npx tsc -b, npx oxlint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions