MCPcopy Index your code
hub / github.com/dagger/dagger / ReactToInput

Method ReactToInput

cmd/dagger/shell.go:583–629  ·  view source on GitHub ↗
(ctx context.Context, ev uv.KeyPressEvent, inputValue string, editing bool)

Source from the content-addressed store, hash-verified

581}
582
583func (h *shellCallHandler) ReactToInput(ctx context.Context, ev uv.KeyPressEvent, inputValue string, editing bool) func() {
584 key := uv.Key(ev)
585 switch {
586 case key.MatchString(">"):
587 if inputValue == "" {
588 h.mode = modePrompt
589 return func() {
590 h.llm(ctx) // initialize LLM
591 }
592 }
593 case key.MatchString("!"):
594 if inputValue == "" {
595 h.mode = modeShell
596 return noop // handled, no async work
597 }
598 case key.MatchString("ctrl+x"):
599 if h.llmSession != nil {
600 h.llmSession.ToggleAutocompact()
601 return noop
602 }
603 case key.MatchString("ctrl+s"):
604 if h.llmSession != nil {
605 return func() {
606 if err := h.llmSession.SyncToLocal(ctx); err != nil {
607 slog.Error("failed to sync changes to local filesystem", "error", err.Error())
608 Frontend.SetSidebarContent(idtui.SidebarSection{
609 Title: "Changes",
610 Content: termenv.String("SAVE ERROR: " + err.Error()).Foreground(termenv.ANSIRed).String(),
611 })
612 }
613 }
614 }
615 case key.MatchString("ctrl+u"):
616 if h.llmSession != nil {
617 return func() {
618 if err := h.llmSession.SyncFromLocal(ctx); err != nil {
619 slog.Error("failed to load current working directory into agent workspace", "error", err.Error())
620 Frontend.SetSidebarContent(idtui.SidebarSection{
621 Title: "Changes",
622 Content: termenv.String("UPLOAD ERROR: " + err.Error()).Foreground(termenv.ANSIRed).String(),
623 })
624 }
625 }
626 }
627 }
628 return nil
629}
630
631func noop() {}
632

Callers

nothing calls this directly

Calls 8

llmMethod · 0.95
ErrorFunction · 0.92
ToggleAutocompactMethod · 0.80
SyncToLocalMethod · 0.80
SyncFromLocalMethod · 0.80
SetSidebarContentMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected