Fix: graceful shutdown in tui, to avoid other key block
This commit is contained in:
14
main.go
14
main.go
@@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gdamore/tcell/v2"
|
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -24,19 +23,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
|
||||||
if event.Key() == tcell.KeyCtrlC {
|
|
||||||
logger.Info("caught Ctrl+C via tcell event")
|
|
||||||
go func() {
|
|
||||||
if err := pwShutDown(); err != nil {
|
|
||||||
logger.Error("shutdown failed", "err", err)
|
|
||||||
}
|
|
||||||
app.Stop()
|
|
||||||
}()
|
|
||||||
return nil // swallow the event
|
|
||||||
}
|
|
||||||
return event
|
|
||||||
})
|
|
||||||
pages.AddPage("main", flex, true, true)
|
pages.AddPage("main", flex, true, true)
|
||||||
if err := app.SetRoot(pages,
|
if err := app.SetRoot(pages,
|
||||||
true).EnableMouse(cfg.EnableMouse).EnablePaste(true).Run(); err != nil {
|
true).EnableMouse(cfg.EnableMouse).EnablePaste(true).Run(); err != nil {
|
||||||
|
|||||||
11
tui.go
11
tui.go
@@ -1001,6 +1001,17 @@ func init() {
|
|||||||
showBotRoleSelectionPopup()
|
showBotRoleSelectionPopup()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
// INFO: shutdown
|
||||||
|
if event.Key() == tcell.KeyCtrlC {
|
||||||
|
logger.Info("caught Ctrl+C via tcell event")
|
||||||
|
go func() {
|
||||||
|
if err := pwShutDown(); err != nil {
|
||||||
|
logger.Error("shutdown failed", "err", err)
|
||||||
|
}
|
||||||
|
app.Stop()
|
||||||
|
}()
|
||||||
|
return nil // swallow the event
|
||||||
|
}
|
||||||
if event.Key() == tcell.KeyCtrlG {
|
if event.Key() == tcell.KeyCtrlG {
|
||||||
// cfg.RAGDir is the directory with files to use with RAG
|
// cfg.RAGDir is the directory with files to use with RAG
|
||||||
// rag load
|
// rag load
|
||||||
|
|||||||
Reference in New Issue
Block a user