diff --git a/internal/terminal/handler/ghinformation.go b/internal/terminal/handler/ghinformation.go index c6fd829..5eae49a 100644 --- a/internal/terminal/handler/ghinformation.go +++ b/internal/terminal/handler/ghinformation.go @@ -43,6 +43,8 @@ type ModelInfo struct { func SetupModelInfo(s *skeleton.Skeleton, githubUseCase gu.UseCase, version pkgversion.Version) *ModelInfo { const releaseURL = "https://github.com/termkit/gama/releases" + modelStatus := SetupModelStatus(s) + return &ModelInfo{ // Initialize core dependencies skeleton: s, @@ -51,7 +53,7 @@ func SetupModelInfo(s *skeleton.Skeleton, githubUseCase gu.UseCase, version pkgv // Initialize UI components help: help.New(), - status: SetupModelStatus(s), + status: modelStatus, keys: githubInformationKeys, // Initialize application state diff --git a/internal/terminal/handler/ghrepository.go b/internal/terminal/handler/ghrepository.go index e876409..8004c71 100644 --- a/internal/terminal/handler/ghrepository.go +++ b/internal/terminal/handler/ghrepository.go @@ -54,6 +54,9 @@ type ModelGithubRepository struct { // ----------------------------------------------------------------------------- func SetupModelGithubRepository(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubRepository { + modelStatus := SetupModelStatus(s) + tabOptions := NewOptions(s, modelStatus) + m := &ModelGithubRepository{ // Initialize core dependencies skeleton: s, @@ -62,9 +65,9 @@ func SetupModelGithubRepository(s *skeleton.Skeleton, githubUseCase gu.UseCase) // Initialize UI components help: help.New(), Keys: githubRepositoryKeys, - status: SetupModelStatus(s), + status: modelStatus, textInput: setupTextInput(), - modelTabOptions: NewOptions(s, SetupModelStatus(s)), + modelTabOptions: tabOptions, // Initialize state selectedRepository: NewSelectedRepository(), diff --git a/internal/terminal/handler/ghtrigger.go b/internal/terminal/handler/ghtrigger.go index 282c180..ad14f77 100644 --- a/internal/terminal/handler/ghtrigger.go +++ b/internal/terminal/handler/ghtrigger.go @@ -69,6 +69,8 @@ type ModelGithubTrigger struct { // ----------------------------------------------------------------------------- func SetupModelGithubTrigger(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubTrigger { + modelStatus := SetupModelStatus(s) + m := &ModelGithubTrigger{ // Initialize core dependencies skeleton: s, @@ -77,7 +79,7 @@ func SetupModelGithubTrigger(s *skeleton.Skeleton, githubUseCase gu.UseCase) *Mo // Initialize UI components help: help.New(), Keys: githubTriggerKeys, - status: SetupModelStatus(s), + status: modelStatus, textInput: setupTriggerInput(), tableTrigger: setupTriggerTable(), diff --git a/internal/terminal/handler/ghworkflow.go b/internal/terminal/handler/ghworkflow.go index ab0d40c..e37754f 100644 --- a/internal/terminal/handler/ghworkflow.go +++ b/internal/terminal/handler/ghworkflow.go @@ -64,6 +64,8 @@ type ModelGithubWorkflow struct { // ----------------------------------------------------------------------------- func SetupModelGithubWorkflow(s *skeleton.Skeleton, githubUseCase gu.UseCase) *ModelGithubWorkflow { + modelStatus := SetupModelStatus(s) + m := &ModelGithubWorkflow{ // Initialize core dependencies skeleton: s, @@ -72,7 +74,7 @@ func SetupModelGithubWorkflow(s *skeleton.Skeleton, githubUseCase gu.UseCase) *M // Initialize UI components help: help.New(), keys: githubWorkflowKeys, - status: SetupModelStatus(s), + status: modelStatus, textInput: setupBranchInput(), // Initialize state @@ -148,10 +150,7 @@ func (m *ModelGithubWorkflow) Init() tea.Cmd { } func (m *ModelGithubWorkflow) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - // Check repository change and return command if exists - if cmd := m.handleRepositoryChange(); cmd != nil { - return m, cmd - } + m.handleRepositoryChange() var cmds []tea.Cmd var cmd tea.Cmd @@ -182,7 +181,7 @@ func (m *ModelGithubWorkflow) View() string { // Repository Change Handling // ----------------------------------------------------------------------------- -func (m *ModelGithubWorkflow) handleRepositoryChange() tea.Cmd { +func (m *ModelGithubWorkflow) handleRepositoryChange() { if m.state.Repository.Current != m.selectedRepository.RepositoryName { m.state.Ready = false m.state.Repository.Current = m.selectedRepository.RepositoryName @@ -191,7 +190,6 @@ func (m *ModelGithubWorkflow) handleRepositoryChange() tea.Cmd { } else if !m.state.Repository.HasFlows { m.skeleton.LockTab("trigger") } - return nil } // ----------------------------------------------------------------------------- diff --git a/internal/terminal/handler/ghworkflowhistory.go b/internal/terminal/handler/ghworkflowhistory.go index bc877c3..46bc808 100644 --- a/internal/terminal/handler/ghworkflowhistory.go +++ b/internal/terminal/handler/ghworkflowhistory.go @@ -68,6 +68,8 @@ func SetupModelGithubWorkflowHistory(s *skeleton.Skeleton, githubUseCase gu.UseC panic(fmt.Sprintf("failed to load config: %v", err)) } + modelStatus := SetupModelStatus(s) + tabOptions := NewOptions(s, modelStatus) m := &ModelGithubWorkflowHistory{ // Initialize core dependencies skeleton: s, @@ -76,8 +78,8 @@ func SetupModelGithubWorkflowHistory(s *skeleton.Skeleton, githubUseCase gu.UseC // Initialize UI components Help: help.New(), keys: githubWorkflowHistoryKeys, - status: SetupModelStatus(s), - modelTabOptions: NewOptions(s, SetupModelStatus(s)), + status: modelStatus, + modelTabOptions: tabOptions, // Initialize state selectedRepository: NewSelectedRepository(), @@ -145,10 +147,7 @@ func (m *ModelGithubWorkflowHistory) Init() tea.Cmd { } func (m *ModelGithubWorkflowHistory) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - // Handle repository changes - if cmd := m.handleRepositoryChange(); cmd != nil { - return m, cmd - } + m.handleRepositoryChange() cursor := m.tableWorkflowHistory.Cursor() if m.workflows != nil && cursor >= 0 && cursor < len(m.workflows) { @@ -174,7 +173,7 @@ func (m *ModelGithubWorkflowHistory) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Update UI components if cmd = m.updateUIComponents(msg); cmd != nil { - cmds = append(cmds, cmd) + cmds = append(cmds, m.updateUIComponents(msg)) } return m, tea.Batch(cmds...)