HarperFast / HarperFast/studio

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

Open
#1,492 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5
Forks
4
Avg merge
1d 8h
Merged PRs (30d)
40

Description

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`.

Contributor guide

Open the contributing guide

Research direction

Start in src/features/instance/databases/components/DatabaseActionModals.tsx and trace the Add New Record(s) trigger, instanceDatabaseMap lookup, and AddTableRowModal inputs. Run npx vitest run src/features/instance/databases before changing behavior. Done means cached tables still open immediately, missing tables show loading while refetching, resolved tables open, and genuinely absent tables show the existing removal toast; verify with npx tsc -b and npx oxlint.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.