Skip to content

Commit cefe2cf

Browse files
committed
[FIX] PostgreSQL support.
1 parent def4e66 commit cefe2cf

3 files changed

Lines changed: 42 additions & 11 deletions

File tree

internal/engine/install/engine.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,19 @@ func (e *Engine) Run(ctx context.Context, ch chan<- domain.Event, actions <-chan
680680
},
681681
})
682682

683+
promptMsg := strings.TrimSpace(msg)
684+
promptMsg = strings.ReplaceAll(promptMsg, "\r", " ")
685+
promptMsg = strings.ReplaceAll(promptMsg, "\n", " ")
686+
promptMsg = strings.Join(strings.Fields(promptMsg), " ")
687+
if len(promptMsg) > 160 {
688+
promptMsg = promptMsg[:160] + "..."
689+
}
690+
683691
retry, ok := askSelect(ctx, emit, actions, dbStepID, domain.QuestionState{
684692
Active: true,
685693
ID: "db_retry",
686694
Kind: domain.QuestionSelect,
687-
Prompt: "Would you like to try again or exit installation?",
695+
Prompt: "Database connection failed: " + promptMsg + " — try again or exit installation?",
688696
Options: []domain.QuestionOption{
689697
{ID: "exit", Label: "Exit installation", Enabled: true},
690698
{ID: "retry", Label: "Try again", Enabled: true},

internal/ui/model.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,33 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
215215
return m, nil
216216
}
217217

218-
// Question handling (engine-driven).
219-
if m.state.Question.Active {
220-
kind := m.state.Question.Kind
221-
if kind == "" {
222-
kind = domain.QuestionSelect
223-
}
218+
// Question handling (engine-driven).
219+
if m.state.Question.Active {
220+
kind := m.state.Question.Kind
221+
if kind == "" {
222+
kind = domain.QuestionSelect
223+
}
224+
225+
// While a question is active, keep an escape hatch for scrolling logs.
226+
// Some terminals/IDEs don't send PgUp/PgDn reliably, so support key chords too.
227+
switch key {
228+
case "shift+up", "ctrl+up":
229+
m.followLogs = false
230+
m.logVP.LineUp(1)
231+
m.reflow()
232+
return m, nil
233+
case "shift+down", "ctrl+down":
234+
m.logVP.LineDown(1)
235+
if m.logVP.AtBottom() {
236+
m.followLogs = true
237+
}
238+
m.reflow()
239+
return m, nil
240+
}
224241

225-
if kind == domain.QuestionInput {
226-
if key == "enter" {
227-
text := m.inputValue
242+
if kind == domain.QuestionInput {
243+
if key == "enter" {
244+
text := m.inputValue
228245
if !m.inputTouched {
229246
text = m.state.Question.Default
230247
}

internal/ui/run.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ func RunWithCancel(ctx context.Context, mode Mode, events <-chan domain.Event, a
5959
}
6060
m.reflow()
6161

62-
p := tea.NewProgram(m, tea.WithAltScreen(), tea.WithInput(in), tea.WithOutput(out))
62+
progOpts := []tea.ProgramOption{tea.WithInput(in), tea.WithOutput(out)}
63+
// Alt screen breaks scrolling in some environments (and can look like "log spam" in IDE consoles).
64+
// Allow disabling it explicitly.
65+
if os.Getenv("EVO_NO_ALT_SCREEN") == "" && os.Getenv("NO_ALT_SCREEN") == "" {
66+
progOpts = append(progOpts, tea.WithAltScreen())
67+
}
68+
p := tea.NewProgram(m, progOpts...)
6369
finalModel, err := p.Run()
6470
res := RunResult{}
6571
if mm, ok := finalModel.(*Model); ok && len(mm.postExecCommand) > 0 {

0 commit comments

Comments
 (0)