diff --git a/app/controllers/commands_controller.rb b/app/controllers/commands_controller.rb index 4424f5ca2..ae5c2232e 100644 --- a/app/controllers/commands_controller.rb +++ b/app/controllers/commands_controller.rb @@ -56,7 +56,11 @@ class CommandsController < ApplicationController def respond_with_composite_response(results) json = results.map(&:as_json).grep(Hash).reduce({}, :merge) - render json: json, status: :accepted + if json.empty? + redirect_back_or_to root_path + else + render json: json, status: :accepted + end end def respond_with_insight_response(chat_response) diff --git a/app/javascript/controllers/terminal_controller.js b/app/javascript/controllers/terminal_controller.js index b575225bb..8d3c2235f 100644 --- a/app/javascript/controllers/terminal_controller.js +++ b/app/javascript/controllers/terminal_controller.js @@ -3,7 +3,7 @@ import { HttpStatus } from "helpers/http_helpers" import { marked } from "marked" export default class extends Controller { - static targets = [ "input", "form", "output", "confirmation" ] + static targets = [ "input", "form", "output", "confirmation", "recentCommands" ] static classes = [ "error", "confirmation", "help", "output", "busy" ] static values = { originalInput: String, waitingForConfirmation: Boolean } @@ -89,6 +89,7 @@ export default class extends Controller { this.#handleJsonResponse(responseJson) }) } + this.recentCommandsTarget.reload() this.#reset() } diff --git a/app/views/commands/_form.html.erb b/app/views/commands/_form.html.erb index aed7234d8..f13de4d5c 100644 --- a/app/views/commands/_form.html.erb +++ b/app/views/commands/_form.html.erb @@ -9,14 +9,12 @@ <%= text_field_tag "command", nil, - id: "terminal_input", autocomplete: "off", autocorrect: "off", autocapitalize: "off", class: "terminal__input input fill-transparent unpad", data: { terminal_target: "input", - turbo_permanent: true, action: "keydown.up->toggle-class#add:prevent keydown.up->navigable-list#selectCurrentOrLast terminal#hideError" }, placeholder: "Press ⌘+K to search or type /commands…", diff --git a/app/views/commands/_terminal.html.erb b/app/views/commands/_terminal.html.erb index 4a2a76e9f..aeb922d2e 100644 --- a/app/views/commands/_terminal.html.erb +++ b/app/views/commands/_terminal.html.erb @@ -10,7 +10,7 @@ terminal_busy_class: "terminal--busy", toggle_class_toggle_class: "terminal--open", action: "keydown->terminal#handleKeyPress keydown->navigable-list#navigate focusin->navigable-list#select keydown.esc->toggle-class#remove:stop keydown.esc->terminal#focus keydown.esc->navigable-list#selectLast keydown.esc@document->terminal#hideMenus" } do %> - <%= turbo_frame_tag :recent_commands, src: commands_path, refresh: "morph" %> + <%= turbo_frame_tag :recent_commands, src: commands_path, data: { terminal_target: "recentCommands" } %> <%= render "commands/form" %> <% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 995eea4dc..ba86f92e4 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -47,7 +47,7 @@ <%= yield :footer %> <% if Current.user && !@hide_footer_frames %> -