Files
VERSE 6ffb9f83f2 feat(scoring): transition workflow learning and fix history UX (#39)
- add transition scoring engine to learn sequential workflows per
directory using command skeletons
- prioritize current active git branch over older branches in
suggestions
- restore strict chronological order for history navigation and bypass
AI re-ranking
- add in-memory session history for instant access to just-run commands
- fix PTY prompt not syncing when using arrow keys in the history menu
- fix history tie-breaker to properly prioritize newer commands by
assigning larger IDs
- fix potential mutex deadlock between bufferMu and pty write during
history navigation
- fix workspace git detection to remove depth limits and correctly
identify repositories with detached HEADs
- fix SQLite connection leaks in frecency queries
- fix global state leaks in history tests by snapshotting and restoring
registry states
- modernize string prefix checks using strings.CutPrefix
2026-07-26 19:10:56 +07:00

53 lines
1.3 KiB
Go

package integration
import (
"testing"
)
func TestRecordSessionCommand_MergeAndDeduplicate(t *testing.T) {
sessionHistoryMu.Lock()
origSessionHistory := sessionHistory
sessionHistory = nil
sessionHistoryMu.Unlock()
mu.Lock()
origHistoryCache := historyCache
historyCache = nil
mu.Unlock()
t.Cleanup(func() {
sessionHistoryMu.Lock()
sessionHistory = origSessionHistory
sessionHistoryMu.Unlock()
mu.Lock()
historyCache = origHistoryCache
mu.Unlock()
})
RecordSessionCommand("git status")
RecordSessionCommand("npm run dev")
RecordSessionCommand("npm run dev") // duplicate subsequent command should be ignored
RecordSessionCommand("git push origin fix/scoring")
results, err := SearchHistory("", nil)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if len(results) < 3 {
t.Fatalf("expected at least 3 session commands in search results, got %d", len(results))
}
// newest session command must be results[0]
if results[0].Cmd != "git push origin fix/scoring" {
t.Errorf("expected results[0] to be 'git push origin fix/scoring', got %q", results[0].Cmd)
}
if results[1].Cmd != "npm run dev" {
t.Errorf("expected results[1] to be 'npm run dev', got %q", results[1].Cmd)
}
if results[2].Cmd != "git status" {
t.Errorf("expected results[2] to be 'git status', got %q", results[2].Cmd)
}
}