f99010fae1
Desktop Artifacts / Desktop Build (Linux) (push) Waiting to run
Desktop Artifacts / Desktop Build (Windows) (push) Waiting to run
Desktop Artifacts / Desktop Build (Linux (arm64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (aarch64)) (push) Waiting to run
Desktop Artifacts (macOS) / Desktop Build (macOS (x86_64)) (push) Waiting to run
CI / lint (push) Failing after 1s
CI / frontend (push) Failing after 1s
CI / scripts (push) Failing after 1s
CI / Go Test (ubuntu-latest) (push) Failing after 0s
CI / frontend-node-25 (push) Failing after 1s
CI / docs (push) Failing after 0s
CI / coverage (push) Failing after 0s
CI / e2e (push) Failing after 0s
Docker / build-and-push (push) Failing after 1s
CI / integration (push) Failing after 4m43s
CI / Go Test (windows-latest) (push) Has been cancelled
CI / Desktop Unit Tests (Windows) (push) Has been cancelled
77 lines
2.2 KiB
Go
77 lines
2.2 KiB
Go
package sync
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.kenn.io/agentsview/internal/dbtest"
|
|
"go.kenn.io/agentsview/internal/parser"
|
|
)
|
|
|
|
func TestProcessFileOpenHandsUsesSnapshotMtimeForRetryCache(t *testing.T) {
|
|
root := t.TempDir()
|
|
sessionDir := filepath.Join(
|
|
root, "086c7ecf6cb746b69fbcb900358d1247",
|
|
)
|
|
eventsDir := filepath.Join(sessionDir, "events")
|
|
require.NoError(t, os.MkdirAll(eventsDir, 0o755))
|
|
|
|
baseStatePath := filepath.Join(sessionDir, "base_state.json")
|
|
eventPath := filepath.Join(eventsDir, "event-00000-user.json")
|
|
dbtest.WriteTestFile(t, baseStatePath, []byte(`{
|
|
"id":"086c7ecf-6cb7-46b6-9fbc-b900358d1247",
|
|
"agent":{"llm":{"model":"openhands-test-model"}}
|
|
}`))
|
|
dbtest.WriteTestFile(t, eventPath, []byte(`{
|
|
"id":"e0",
|
|
"timestamp":"2026-04-02T15:25:40.706887",
|
|
"source":"user",
|
|
"llm_message":{"role":"user","content":[{"type":"text","text":"First version"}]},
|
|
"kind":"MessageEvent"
|
|
}`))
|
|
|
|
dirInfo, err := os.Stat(sessionDir)
|
|
require.NoError(t, err)
|
|
oldDirMtime := dirInfo.ModTime()
|
|
|
|
engine := &Engine{
|
|
db: dbtest.OpenTestDB(t),
|
|
machine: "local",
|
|
agentDirs: map[parser.AgentType][]string{
|
|
parser.AgentOpenHands: {root},
|
|
},
|
|
providerFactories: providerFactoryMap(parser.ProviderFactories()),
|
|
providerMigrationModes: map[parser.AgentType]parser.ProviderMigrationMode{
|
|
parser.AgentOpenHands: parser.ProviderMigrationProviderAuthoritative,
|
|
},
|
|
skipCache: map[string]int64{sessionDir: oldDirMtime.UnixNano()},
|
|
}
|
|
|
|
time.Sleep(10 * time.Millisecond)
|
|
dbtest.WriteTestFile(t, eventPath, []byte(`{
|
|
"id":"e0",
|
|
"timestamp":"2026-04-02T15:25:41.706887",
|
|
"source":"user",
|
|
"llm_message":{"role":"user","content":[{"type":"text","text":"Updated version"}]},
|
|
"kind":"MessageEvent"
|
|
}`))
|
|
require.NoError(t, os.Chtimes(sessionDir, oldDirMtime, oldDirMtime))
|
|
|
|
snapshot, err := parser.OpenHandsSnapshot(sessionDir)
|
|
require.NoError(t, err)
|
|
require.NotEqual(t, oldDirMtime.UnixNano(), snapshot.Mtime)
|
|
|
|
res := engine.processFile(context.Background(), parser.DiscoveredFile{
|
|
Path: sessionDir,
|
|
Agent: parser.AgentOpenHands,
|
|
})
|
|
require.False(t, res.skip)
|
|
require.NoError(t, res.err)
|
|
require.Len(t, res.results, 1)
|
|
require.Equal(t, snapshot.Mtime, res.mtime)
|
|
}
|