Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func TestSearchCmd_JSON(t *testing.T) {
if len(results) == 0 {
t.Fatal("expected at least 1 search result")
}
if _, ok := results[0]["session"]; !ok {
t.Fatal("expected session field in result")
if _, ok := results[0]["id"]; !ok {
t.Fatal("expected id field in result (flattened session)")
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type CLI struct {

Default DefaultCmd `cmd:"" default:"noargs" hidden:""`
List ListCmd `cmd:"" help:"List recent sessions"`
Search SearchCmd `cmd:"" help:"Search session content"`
Search SearchCmd `cmd:"" help:"Search session content\n\nJSON fields: id, short_id, project_name, project_path, created, modified, first_prompt, git_branch, message_count, matches, score\n\nExample: cct search 'query' --json | jq '.[] | {short_id, project_name, created}'"`
Info InfoCmd `cmd:"" help:"Show session metadata and first prompt"`
Resume ResumeCmd `cmd:"" help:"Resume a session (auto-switches directory)"`
Export ExportCmd `cmd:"" help:"Export session messages (with filtering)"`
Expand Down
8 changes: 4 additions & 4 deletions internal/app/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ func (cmd *PlansSearchCmd) Run(globals *Globals) error {
for _, m := range matches {
tbl.Row(
[]string{
output.Truncate(m.Plan.Name, tbl.ColWidth(0)),
output.FormatAge(m.Plan.Modified),
output.Truncate(m.Plan.Title, tbl.ColWidth(2)),
output.Truncate(m.Name, tbl.ColWidth(0)),
output.FormatAge(m.Modified),
output.Truncate(m.Title, tbl.ColWidth(2)),
m.Snippet,
},
[]func(string) string{output.Dim, output.Dim, output.Bold, nil},
Expand All @@ -147,7 +147,7 @@ func (cmd *PlansSearchCmd) Run(globals *Globals) error {

if len(matches) > 0 {
fmt.Println()
fmt.Printf(" %s\n", output.Cyan(fmt.Sprintf("cct plans cp %s", matches[0].Plan.Name)))
fmt.Printf(" %s\n", output.Cyan(fmt.Sprintf("cct plans cp %s", matches[0].Name)))
}
fmt.Println()
return nil
Expand Down
8 changes: 4 additions & 4 deletions internal/index/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ func TestSearch_CompoundTermFiltering(t *testing.T) {
if len(results) != 1 {
t.Fatalf("expected 1 result for 'pre-commit', got %d", len(results))
}
if results[0].Session.ID != "match111-2222-3333-4444-555555555555" {
t.Errorf("expected matching session, got %s", results[0].Session.ID)
if results[0].ID != "match111-2222-3333-4444-555555555555" {
t.Errorf("expected matching session, got %s", results[0].ID)
}
}

Expand Down Expand Up @@ -534,8 +534,8 @@ func TestSearch_CrossMessageMultiTerm(t *testing.T) {
if len(results) != 1 {
t.Fatalf("expected 1 result for cross-message 'fix bug', got %d", len(results))
}
if results[0].Session.ID != "cross111-2222-3333-4444-555555555555" {
t.Errorf("expected cross-message session, got %s", results[0].Session.ID)
if results[0].ID != "cross111-2222-3333-4444-555555555555" {
t.Errorf("expected cross-message session, got %s", results[0].ID)
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/index/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type SearchOptions struct {
}

type SearchResult struct {
Session *session.Session `json:"session"`
Matches []session.Match `json:"matches"`
Score float64 `json:"score"`
*session.Session
Matches []session.Match `json:"matches"`
Score float64 `json:"score"`
}

type sessionInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/plan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func SearchPlans(query string, snippetWidth int) ([]PlanMatch, error) {
}

type PlanMatch struct {
Plan Plan `json:"plan"`
Plan
Snippet string `json:"snippet"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/plan/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func TestSearchPlans(t *testing.T) {
if len(matches) != 1 {
t.Fatalf("expected 1 match, got %d", len(matches))
}
if matches[0].Plan.Name != "auth-refactor" {
t.Errorf("matched plan = %q, want auth-refactor", matches[0].Plan.Name)
if matches[0].Name != "auth-refactor" {
t.Errorf("matched plan = %q, want auth-refactor", matches[0].Name)
}
})

Expand Down
4 changes: 2 additions & 2 deletions internal/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type Match struct {
}

type SearchResult struct {
Session *Session `json:"session"`
Matches []Match `json:"matches"`
*Session
Matches []Match `json:"matches"`
}

func ExtractIDFromFilename(path string) string {
Expand Down
Loading