Add StartupNudge function for unified session metadata (gt-bgfqy)
Creates internal/session/startup.go with StartupNudgeConfig struct and StartupNudge function. Format becomes session title in /resume picker: [GAS TOWN] recipient <- sender • timestamp • topic[:mol-id] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
b020b2634e
commit
172d5f7402
103
internal/session/startup_test.go
Normal file
103
internal/session/startup_test.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFormatStartupNudge(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
cfg StartupNudgeConfig
|
||||
wantSub []string // substrings that must appear
|
||||
wantNot []string // substrings that must NOT appear
|
||||
}{
|
||||
{
|
||||
name: "assigned with mol-id",
|
||||
cfg: StartupNudgeConfig{
|
||||
Recipient: "gastown/crew/gus",
|
||||
Sender: "deacon",
|
||||
Topic: "assigned",
|
||||
MolID: "gt-abc12",
|
||||
},
|
||||
wantSub: []string{
|
||||
"[GAS TOWN]",
|
||||
"gastown/crew/gus",
|
||||
"<- deacon",
|
||||
"assigned:gt-abc12",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "cold-start no mol-id",
|
||||
cfg: StartupNudgeConfig{
|
||||
Recipient: "deacon",
|
||||
Sender: "mayor",
|
||||
Topic: "cold-start",
|
||||
},
|
||||
wantSub: []string{
|
||||
"[GAS TOWN]",
|
||||
"deacon",
|
||||
"<- mayor",
|
||||
"cold-start",
|
||||
},
|
||||
// No wantNot - timestamp contains ":"
|
||||
},
|
||||
{
|
||||
name: "handoff self",
|
||||
cfg: StartupNudgeConfig{
|
||||
Recipient: "gastown/witness",
|
||||
Sender: "self",
|
||||
Topic: "handoff",
|
||||
},
|
||||
wantSub: []string{
|
||||
"[GAS TOWN]",
|
||||
"gastown/witness",
|
||||
"<- self",
|
||||
"handoff",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "mol-id only",
|
||||
cfg: StartupNudgeConfig{
|
||||
Recipient: "gastown/polecats/Toast",
|
||||
Sender: "witness",
|
||||
MolID: "gt-xyz99",
|
||||
},
|
||||
wantSub: []string{
|
||||
"[GAS TOWN]",
|
||||
"gastown/polecats/Toast",
|
||||
"<- witness",
|
||||
"gt-xyz99",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty topic defaults to ready",
|
||||
cfg: StartupNudgeConfig{
|
||||
Recipient: "deacon",
|
||||
Sender: "mayor",
|
||||
},
|
||||
wantSub: []string{
|
||||
"[GAS TOWN]",
|
||||
"ready",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := FormatStartupNudge(tt.cfg)
|
||||
|
||||
for _, sub := range tt.wantSub {
|
||||
if !strings.Contains(got, sub) {
|
||||
t.Errorf("FormatStartupNudge() = %q, want to contain %q", got, sub)
|
||||
}
|
||||
}
|
||||
|
||||
for _, sub := range tt.wantNot {
|
||||
if strings.Contains(got, sub) {
|
||||
t.Errorf("FormatStartupNudge() = %q, should NOT contain %q", got, sub)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user