@@ -14,7 +14,7 @@ import (
1414 "go.kenn.io/agentsview/internal/db"
1515)
1616
17- func TestPGSessionIdentityVisibleInReadPaths (t * testing.T ) {
17+ func TestPGClaudeProvenanceVisibleInReadPaths (t * testing.T ) {
1818 pgURL := testPGURL (t )
1919
2020 const schema = "agentsview_session_identity_test"
@@ -38,13 +38,22 @@ func TestPGSessionIdentityVisibleInReadPaths(t *testing.T) {
3838 Agent : "claude" ,
3939 AgentLabel : "triage" ,
4040 Entrypoint : "sdk-cli" ,
41+ SessionKind : "bg" ,
4142 MessageCount : 1 ,
4243 UserMessageCount : 1 ,
4344 CreatedAt : "2026-01-01T00:00:00Z" ,
4445 StartedAt : strPtr ("2026-01-01T00:00:00Z" ),
4546 EndedAt : strPtr ("2026-01-01T01:00:00Z" ),
4647 }
4748 require .NoError (t , localDB .UpsertSession (sess ), "UpsertSession" )
49+ require .NoError (t , localDB .InsertMessages ([]db.Message {{
50+ SessionID : sess .ID ,
51+ Ordinal : 0 ,
52+ Role : "user" ,
53+ Content : "hello" ,
54+ ContentLength : 5 ,
55+ PromptSource : "typed" ,
56+ }}), "InsertMessages" )
4857
4958 sync := & Sync {
5059 pg : pg ,
@@ -56,14 +65,15 @@ func TestPGSessionIdentityVisibleInReadPaths(t *testing.T) {
5665 _ , pushErr := sync .Push (ctx , true , nil )
5766 require .NoError (t , pushErr , "Push" )
5867
59- var agentLabel sql.NullString
60- var entrypoint sql.NullString
68+ var agentLabel , entrypoint , sessionKind sql.NullString
6169 require .NoError (t , pg .QueryRowContext (ctx ,
62- `SELECT agent_label, entrypoint FROM sessions WHERE id = $1` ,
70+ `SELECT agent_label, entrypoint, session_kind
71+ FROM sessions WHERE id = $1` ,
6372 sess .ID ,
64- ).Scan (& agentLabel , & entrypoint ), "query raw PG row" )
73+ ).Scan (& agentLabel , & entrypoint , & sessionKind ), "query raw PG row" )
6574 assert .Equal (t , "triage" , agentLabel .String )
6675 assert .Equal (t , "sdk-cli" , entrypoint .String )
76+ assert .Equal (t , "bg" , sessionKind .String )
6777
6878 store , err := NewStore (pgURL , schema , true )
6979 require .NoError (t , err , "NewStore" )
@@ -76,10 +86,17 @@ func TestPGSessionIdentityVisibleInReadPaths(t *testing.T) {
7686 require .Len (t , idx .Sessions , 1 , "expected one session in sidebar index" )
7787 assert .Equal (t , "triage" , idx .Sessions [0 ].AgentLabel )
7888 assert .Equal (t , "sdk-cli" , idx .Sessions [0 ].Entrypoint )
89+ assert .Equal (t , "bg" , idx .Sessions [0 ].SessionKind )
7990
8091 full , err := store .GetSession (ctx , sess .ID )
8192 require .NoError (t , err , "GetSession" )
8293 require .NotNil (t , full , "GetSession must return the session" )
8394 assert .Equal (t , "triage" , full .AgentLabel )
8495 assert .Equal (t , "sdk-cli" , full .Entrypoint )
96+ assert .Equal (t , "bg" , full .SessionKind )
97+
98+ messages , err := store .GetMessages (ctx , sess .ID , 0 , 10 , true )
99+ require .NoError (t , err , "GetMessages" )
100+ require .Len (t , messages , 1 )
101+ assert .Equal (t , "typed" , messages [0 ].PromptSource )
85102}
0 commit comments