Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions .gemini/settings.json

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ extension ConnectionSession {
metadataFreshnessByDatabase.removeAll()
return
}
// Mark cached databases with schemas AND column data as .live so the first expand is instant.
// Databases whose objects lack column data (e.g. saved when a server was unreachable or had
// a schema-load failure) are treated as .listOnly so the background prefetch reloads them.
metadataFreshnessByDatabase = Self.makeMetadataFreshnessMap(
from: structure,
loadedState: .cached,
loadedState: .live,
preserveExisting: false,
existing: [:]
existing: [:],
requireColumns: true
)
}

Expand Down Expand Up @@ -73,17 +77,42 @@ extension ConnectionSession {
loadedState: DatabaseMetadataFreshness,
preserveExisting: Bool,
existing: [String: DatabaseMetadataFreshness],
liveDatabases: Set<String> = []
liveDatabases: Set<String> = [],
requireColumns: Bool = false
) -> [String: DatabaseMetadataFreshness] {
var next: [String: DatabaseMetadataFreshness] = [:]
for database in structure.databases {
let key = database.name.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
guard !key.isEmpty else { continue }
let hasSchemas = database.schemas.contains(where: { !$0.objects.isEmpty })
if !hasSchemas {
next[key] = .listOnly
// Preserve live/refreshing state even when the incoming structure has no schemas.
// MSSQL (and MySQL) initial fetches return empty schemas intentionally — they do a
// list-only load and rely on per-database lazy loads for schema detail.
// Overriding a .live database with .listOnly forces an unnecessary re-fetch every
// time the background structure refresh completes.
if preserveExisting, let state = existing[key], state == .live || state == .refreshing {
next[key] = .live
} else {
next[key] = .listOnly
}
continue
}
// When hydrating from cache (requireColumns = true), treat databases whose table/view
// objects have no column data as .listOnly. This forces the background prefetch to
// reload them, which happens when the server was previously unreachable (e.g. version
// mismatch causing all schema loads to fail) or when columns were never persisted.
if requireColumns {
let hasColumns = database.schemas.contains(where: { schema in
schema.objects.contains(where: { obj in
(obj.type == .table || obj.type == .view) && !obj.columns.isEmpty
})
})
if !hasColumns {
next[key] = .listOnly
continue
}
}
if liveDatabases.contains(key) {
next[key] = .live
continue
Expand Down
Loading
Loading