aboutsummaryrefslogtreecommitdiff
path: root/internal/app/model.go
blob: 7a01cd688a1db4c6c11de53449e4ba105f304117 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package app

import (
	"github.com/Fuwn/faustus/internal/claude"
	"github.com/Fuwn/faustus/internal/ui"
	"github.com/charmbracelet/bubbles/textinput"
	tea "github.com/charmbracelet/bubbletea"
	"time"
)

type Tab int

const (
	TabSessions Tab = iota
	TabTrash
)

type Mode int

const (
	ModeNormal Mode = iota
	ModeSearch
	ModeDeepSearch
	ModeRename
	ModeConfirm
	ModeReassign
)

type ConfirmAction int

const (
	ConfirmNone ConfirmAction = iota
	ConfirmDelete
	ConfirmRestore
	ConfirmEmptyTrash
	ConfirmPermanentDelete
)

type Model struct {
	sessions             []claude.Session
	filtered             []claude.Session
	cursor               int
	offset               int
	width                int
	height               int
	tab                  Tab
	mode                 Mode
	confirmAction        ConfirmAction
	searchInput          textinput.Model
	renameInput          textinput.Model
	keys                 ui.KeyMap
	showHelp             bool
	message              string
	messageTime          time.Time
	showPreview          bool
	previewFocus         bool
	previewScroll        int
	previewCache         *claude.PreviewContent
	previewFor           string
	deepSearchInput      textinput.Model
	deepSearchResults    []claude.SearchResult
	deepSearchIndex      int
	deepSearchQuery      string
	previewSearchQuery   string
	previewSearchMatches []int
	previewSearchIndex   int
	reassignInput        textinput.Model
	reassignAll          bool
}

func NewModel(sessions []claude.Session) Model {
	searchInput := textinput.New()
	searchInput.Placeholder = "Filter sessions"
	searchInput.CharLimit = 100
	searchInput.Width = 40
	renameInput := textinput.New()
	renameInput.Placeholder = "Enter new name"
	renameInput.CharLimit = 200
	renameInput.Width = 60
	deepSearchInput := textinput.New()
	deepSearchInput.Placeholder = "Search all sessions"
	deepSearchInput.CharLimit = 100
	deepSearchInput.Width = 50
	reassignInput := textinput.New()
	reassignInput.Placeholder = "Enter new project path"
	reassignInput.CharLimit = 500
	reassignInput.Width = 80
	model := Model{
		sessions:        sessions,
		keys:            ui.DefaultKeyMap(),
		searchInput:     searchInput,
		renameInput:     renameInput,
		deepSearchInput: deepSearchInput,
		reassignInput:   reassignInput,
		showPreview:     false,
	}

	model.updateFiltered()

	return model
}

func (m Model) Init() tea.Cmd {
	return textinput.Blink
}