@@ -678,6 +678,16 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
678678 }
679679 return m , tea .Batch (cmds ... )
680680
681+ case explainQueryFromPaletteMsg :
682+ drv := ""
683+ if c := m .findConn (m .activeConnID ); c != nil {
684+ drv = c .Driver
685+ }
686+ if m .editor .WrapCurrentQueryExplain (drv ) {
687+ m .persistEditorDraft ()
688+ }
689+ return m , nil
690+
681691 case clearEditorMsg :
682692 m .editor .ClearUndoable ()
683693 m .persistEditorDraft ()
@@ -1201,6 +1211,7 @@ func (m *Model) openPalette() {
12011211 title = "Editor Commands"
12021212 commands = []cmdpalette.Command {
12031213 {Key : "x" , Description : "Execute query (enter)" , Action : func () tea.Msg { return execQueryFromPaletteMsg {} }},
1214+ {Key : "e" , Description : "Explain current query" , Action : func () tea.Msg { return explainQueryFromPaletteMsg {} }},
12041215 {Key : "c" , Description : "Clear editor" , Action : func () tea.Msg { return clearEditorMsg {} }},
12051216 {Key : "D" , Description : "Close tab (confirm)" , Action : func () tea.Msg { return closeTabPromptMsg {} }},
12061217 {Key : "t" , Description : "Toggle explorer" , Action : func () tea.Msg { return toggleExplorerMsg {} }},
@@ -1658,6 +1669,7 @@ const helpScreenText = `
16581669 r Focus results
16591670 a Focus AI pane (shows it if hidden; does not hide — use palette)
16601671 space Open command palette (context-aware)
1672+ space+e Editor palette: wrap query for EXPLAIN (driver-specific)
16611673 space+f Toggle fullscreen for current panel
16621674 ? Toggle this help
16631675
@@ -1726,7 +1738,7 @@ const helpScreenText = `
17261738
17271739 COMMAND PALETTE (space, then key)
17281740 Explorer: n=add connection e=edit d=delete R=refresh t=toggle explorer a=toggle AI pane f=fullscreen
1729- Editor: x=execute c=clear D=close tab (popup: y/enter · n esc q) t=toggle explorer a=toggle AI pane f=fullscreen
1741+ Editor: x=execute e=explain c=clear D=close tab (popup: y/enter · n esc q) t=toggle explorer a=toggle AI pane f=fullscreen
17301742 Results: y=copy cell Y=copy row e=export CSV j=export JSON t=toggle explorer a=toggle AI pane f=fullscreen
17311743 AI: t=toggle explorer a=toggle AI pane f=fullscreen
17321744`
@@ -1966,7 +1978,8 @@ func (m *Model) execQueryCmd(query string) tea.Cmd {
19661978 var result * db.QueryResult
19671979 if strings .HasPrefix (trimmed , "SELECT" ) || strings .HasPrefix (trimmed , "WITH" ) ||
19681980 strings .HasPrefix (trimmed , "SHOW" ) || strings .HasPrefix (trimmed , "EXPLAIN" ) ||
1969- strings .HasPrefix (trimmed , "DESCRIBE" ) || strings .HasPrefix (trimmed , "DESC" ) {
1981+ strings .HasPrefix (trimmed , "DESCRIBE" ) || strings .HasPrefix (trimmed , "DESC" ) ||
1982+ strings .HasPrefix (trimmed , "SET SHOWPLAN_ALL ON" ) {
19701983 result , err = driver .Query (ctx , dbName , query )
19711984 } else {
19721985 result , err = driver .Exec (ctx , dbName , query )
0 commit comments