Documentation
¶
Overview ¶
Package querylog owns query-log history persistence: the scoped SQLite store, legacy migration, saved-queries import, and retention pruning. It has no Bubble Tea dependency; paging and rendering belong to the workbench query-log UI.
Index ¶
- Constants
- type Entry
- type Model
- func (m Model) AllEntries() []Entry
- func (m *Model) Append(entry Entry)
- func (m *Model) Blur()
- func (m *Model) ClearPendingG()
- func (m *Model) Click(paneX, contentY int)
- func (m *Model) CloseDetail()
- func (m Model) DetailOpen() bool
- func (m Model) Draw(canvas uv.ScreenBuffer, layout uikit.Layout)
- func (m *Model) EnsureCursor()
- func (m *Model) Focus()
- func (m Model) HasRows() bool
- func (m *Model) OpenDetailAtCursor()
- func (m Model) PageCount() int
- func (m *Model) RefreshViewport(width int)
- func (m *Model) Render()
- func (m *Model) Reset()
- func (m *Model) Resize(layout uikit.Layout)
- func (m *Model) RevealColumn(viewportWidth int)
- func (m *Model) Select(row, col int)
- func (m Model) SelectedCellText() (string, bool)
- func (m Model) SelectedEntry() (Entry, bool)
- func (m Model) SelectedStatement() (string, bool)
- func (m *Model) SetEntries(entries []Entry)
- func (m *Model) SetPage(page int)
- func (m Model) Summary() string
- func (m Model) Update(msg tea.Msg, layout uikit.Layout, keys uikit.KeyMatcher) (Model, uikit.Event, tea.Cmd)
- func (m Model) View(layout uikit.Layout) string
- func (m *Model) Wheel(step, hStep int)
- type Store
Constants ¶
const Limit = 100
Limit caps the in-memory entry list and the persisted rows per scope.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
StartedAt time.Time
Statement string
Duration time.Duration
Message string
Status string // "success", "failed", "canceled"
// Language is the backend statement language (e.g. "redis") when the
// backend supplied it; empty for legacy entries.
Language string
// Replayable reports whether the statement may be copied or re-run.
// Legacy entries and entries without metadata default to true;
// sensitive entries are forced false before persistence.
Replayable bool
// Sensitive marks a statement that must never be stored verbatim.
Sensitive bool
// Hint is optional backend-supplied advisory guidance explaining a
// failed execution (perk/v1 error data.hint). It is in-memory only —
// never persisted — and never merged into Message or any identity
// used for matching or diagnostics; the detail view renders it
// separately, labeled, and empty means absent.
Hint string
// SuggestedStatement is optional backend-supplied advisory guidance:
// a statement the user may try instead of the failed one (perk/v1
// error data.suggested_statement). Advisory only — the workbench
// never executes it. In-memory only, never persisted, never merged
// into Message; empty means absent.
SuggestedStatement string
}
Entry is one recorded query execution.
type Model ¶
type Model struct {
Table table.Model
Entries []Entry
Detail *Entry
Page int
PageSize int
PendingG bool
Column int
Offset int
// ViewportWidth is the pane content width used by Render; View and
// root layout refreshes update it.
ViewportWidth int
}
Model is the query-log feature component: the table pane, paging state, the selected column/offset, the detail overlay, and the entry list. Root owns the persistence store and screen geometry; the component owns every interaction and renders its own pane and overlays.
func (Model) AllEntries ¶
AllEntries returns the current entry list (root reads it for chat context and tests; the component owns all writes).
func (*Model) ClearPendingG ¶
func (m *Model) ClearPendingG()
ClearPendingG drops the armed top-first gate.
func (*Model) Click ¶
Click selects the row and column under a pane click. paneX is the click x relative to the pane's content origin; contentY is relative to the pane title row (title at 0, table header at 1, data rows from 2).
func (Model) DetailOpen ¶
DetailOpen reports whether the detail overlay is visible.
func (Model) Draw ¶
func (m Model) Draw(canvas uv.ScreenBuffer, layout uikit.Layout)
Draw renders the detail overlay when open. The root calls Draw at the query-log detail precedence slot and draws the notification popup over the result.
func (*Model) EnsureCursor ¶
func (m *Model) EnsureCursor()
EnsureCursor places the cursor on row 0 when the table has rows and no cursor yet (focus entry).
func (*Model) OpenDetailAtCursor ¶
func (m *Model) OpenDetailAtCursor()
OpenDetailAtCursor opens the detail overlay for the selected entry.
func (*Model) RefreshViewport ¶
RefreshViewport records the pane content width and re-renders the table columns (root's layout width-change pass).
func (*Model) Render ¶
func (m *Model) Render()
Render rebuilds the table columns and rows from the current page.
func (*Model) Reset ¶
func (m *Model) Reset()
Reset clears the entry list, paging, selection, and detail overlay in place, keeping the sized table so the disconnect layout pass survives.
func (*Model) Resize ¶
Resize records the pane viewport width and fits the table height to the pane, mirroring the root layout equation (the header line is the one-row difference between the pane height and the table viewport). Root calls it from its layout pass.
func (*Model) RevealColumn ¶
RevealColumn pans the viewport so the selected column is visible (root calls it from its layout pass).
func (Model) SelectedCellText ¶
SelectedCellText returns the raw text of the selected cell for copying.
func (Model) SelectedEntry ¶
SelectedEntry returns the entry under the table cursor, if any.
func (Model) SelectedStatement ¶
SelectedStatement returns the selected entry's statement for EXPLAIN.
func (*Model) SetEntries ¶
SetEntries replaces the entry list and re-renders the table.
func (Model) Update ¶
func (m Model) Update(msg tea.Msg, layout uikit.Layout, keys uikit.KeyMatcher) (Model, uikit.Event, tea.Cmd)
Update handles query-log messages: the detail overlay consumes everything while open; otherwise the pane's keybindings, table passthrough, and pending-G logic run. The context-menu key and the pane focus switch stay in root (they need screen geometry); root routes them before calling Update. Events ask root for side effects the component cannot perform itself.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a lazily opened scoped query-log database shared by every save and load. It owns exactly one *sql.DB.
func Open ¶
Open opens (creating and migrating if needed) the query-log database at path. retentionDays is the resolved history window applied on each prune; 0 discards history for a scope immediately.