Conversation
|
resolve conflicts |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 27597558 | Triggered | Generic Private Key | 3e9daa6 | SECURITY_REMEDIATION_PR463.md | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
There was a problem hiding this comment.
Pull request overview
Implements persistent “viewer” UI state across runs by adding a dedicated SQLite-backed store for per-transaction visible sections and globally recent search queries, then wiring it into debug, search, and session resume.
Changes:
- Add
internal/session/UIStateStore(SQLite at~/.erst/ui_state.db) to persist section visibility per tx hash and deduped recent searches. - Integrate UI state restore/persist into
erst debug, and surface it inerst session resume. - Add
erst search --recentand persist search terms after successful searches.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/session/uistate.go | New SQLite-backed persistence layer for per-tx visible sections and recent searches |
| internal/session/uistate_test.go | Unit tests covering UI state persistence, dedupe, and trimming behavior |
| internal/cmd/debug.go | Loads/restores prior visible sections; persists visible sections after analysis |
| internal/cmd/search.go | Adds --recent output and persists search terms after successful searches |
| internal/cmd/session.go | Displays persisted viewer state + recent searches on session resume |
Comments suppressed due to low confidence (1)
internal/cmd/search.go:84
errors.WrapValidationError(...)is used in this file, butgithub.com/dotandev/hintents/internal/errorsis no longer imported, so this won’t compile. Re-add theinternal/errorsimport (or update the error handling to not referenceerrors).
store, err := db.InitDB()
if err != nil {
return errors.WrapValidationError(fmt.Sprintf("failed to initialize session database: %v", err))
}
params := db.SearchParams{
TxHash: searchTxFlag,
ErrorRegex: searchErrorFlag,
EventRegex: searchEventFlag,
Limit: searchLimitFlag,
}
sessions, err := store.SearchSessions(params)
if err != nil {
return errors.WrapValidationError(fmt.Sprintf("search failed: %v", err))
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| LIMIT ? | ||
| ) | ||
| `, maxRecentSearches) | ||
| return err |
There was a problem hiding this comment.
AppendRecentSearch returns the raw error from the trimming DELETE without wrapping, which is inconsistent with the other methods in this file (they add context via fmt.Errorf("...: %w", err)). Wrap/annotate the error here as well so callers get actionable context when trimming fails.
| return err | |
| if err != nil { | |
| return fmt.Errorf("failed to trim recent searches: %w", err) | |
| } | |
| return nil |
| if searchRecentFlag { | ||
| uiStore, err := session.NewUIStateStore() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to open viewer state: %w", err) | ||
| } | ||
| defer uiStore.Close() | ||
| queries, err := uiStore.RecentSearches(cmd.Context(), 10) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to load recent searches: %w", err) | ||
| } |
There was a problem hiding this comment.
The PR description/checklist says UIState operations are “best-effort (never abort the parent command)”, but --recent currently returns an error if the UI state DB can’t be opened/read. Consider making erst search --recent degrade gracefully (e.g., print a warning / “No recent searches.” and exit 0) to match the stated best-effort behavior.
| return nil, err | ||
| } | ||
| _ = os.Chmod(dbPath, 0600) | ||
| return s, nil |
There was a problem hiding this comment.
os.Chmod(dbPath, 0600) errors are ignored. If chmod fails (e.g., on Windows or restrictive filesystems), the DB may be left with broader permissions than intended. Handle and surface this failure (at least log a warning, similar to internal/session/store.go) so users aren’t silently left with an insecure file mode.
|
@dotandev CONFLICTS FIXED |
PR: Persistent UI State Across Viewer Sessions (Issue #312)
Closes #312
Summary
When a user reopens a previously debugged transaction the output context is now
automatically restored: which sections were active last time is printed at the
start of the debug run, and any search queries typed into
erst searcharesaved for instant recall with
erst search --recent.Changes
internal/session/uistate.go(new)Introduces
UIStateStore, a lightweight SQLite-backed store at~/.erst/ui_state.dbthat is completely separate from the session store toavoid schema conflicts.
Two tables:
tx_ui_staterecent_searchesPublic API:
NewUIStateStore() (*UIStateStore, error)SaveSectionState(ctx, txHash, []string) errorLoadSectionState(ctx, txHash) ([]string, error)AppendRecentSearch(ctx, query string) errorRecentSearches(ctx, limit int) ([]string, error)Close() errorinternal/session/uistate_test.go(new)Nine tests covering every behaviour path:
TestSaveSectionStateTestLoadSectionState_NoEntryTestSaveSectionState_OverwritesPreviousTestSaveSectionState_IndependentPerTxHashTestAppendRecentSearchTestAppendRecentSearch_DeduplicationTestAppendRecentSearch_TrimToMaxmaxRecentSearchesTestRecentSearches_EmptyTestAppendRecentSearch_EmptyQueryIgnoredinternal/cmd/debug.goUIStateStoreright after the transaction hash is resolved (best-effort;failure does not abort the debug run).
hasTokenFlows).uiStore.SaveSectionStatewith the computed section list.collectVisibleSectionsderives the list from the simulationresponse, security findings, and token-flow flag.
internal/cmd/search.go--recentflag:erst search --recentprints the last 10 search queriesordered newest-first and exits immediately.
--error,--event,--tx) is persisted viaUIStateStore.AppendRecentSearch(best-effort).internal/cmd/session.goerst session resume <id>now shows persisted viewer state at the end of itsoutput when data is available:
Test Results
Build:

go build ./...exits 0 with no warnings.Checklist
go build ./...— clean, 0 errors, 0 warningsgo test ./internal/session/...— 9/9 passTestSearchUnicode_Mixedfailure persists)erst search --recentshows past queries without requiring a new searcherst session resumesurfaces saved section state and recent searches