diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb
index cf18e1281..e2f21b1c6 100644
--- a/app/controllers/conversations_controller.rb
+++ b/app/controllers/conversations_controller.rb
@@ -1,4 +1,8 @@
class ConversationsController < ApplicationController
+ def create
+ Conversation.create_or_find_by(user: Current.user)
+ end
+
def show
@conversation = Current.user.conversation
end
diff --git a/app/javascript/controllers/bar_controller.js b/app/javascript/controllers/bar_controller.js
new file mode 100644
index 000000000..d8e3eb1de
--- /dev/null
+++ b/app/javascript/controllers/bar_controller.js
@@ -0,0 +1,29 @@
+import { Controller } from "@hotwired/stimulus"
+import { post } from "@rails/request.js"
+
+export default class extends Controller {
+ static targets = [ "modalTurboFrame" ]
+ static outlets = [ "dialog" ]
+ static values = {
+ searchUrl: String,
+ searchTurboFrameName: String,
+ askUrl: String,
+ askTurboFrameName: String
+ }
+
+ search() {
+ this.#openInTurboFrame(this.searchTurboFrameNameValue, this.searchUrlValue)
+ this.dialogOutlet.open()
+ }
+
+ async ask() {
+ post(this.askUrlValue)
+ this.#openInTurboFrame(this.askTurboFrameNameValue, this.askUrlValue)
+ this.dialogOutlet.open()
+ }
+
+ #openInTurboFrame(name, url) {
+ this.modalTurboFrameTarget.id = name
+ this.modalTurboFrameTarget.src = url
+ }
+}
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 1d72a8bb8..836fb99f5 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -20,7 +20,7 @@
<% if Current.user && !@hide_footer_frames %>
<% end %>
diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb
index e734a4391..11394df5e 100644
--- a/app/views/searches/show.html.erb
+++ b/app/views/searches/show.html.erb
@@ -12,27 +12,29 @@
<% end %>
-<%= auto_submit_form_with url: searches_queries_path(q: @query_terms), method: :post %>
+<%= turbo_frame_tag "search", target: :_top do %>
+ <%= auto_submit_form_with url: searches_queries_path(q: @query_terms), method: :post %>
-
- <%= render "searches/form", query_terms: @query_terms %>
+
+ <%= render "searches/form", query_terms: @query_terms %>
-
- <% if @query_terms.present? && @search_results.none? %>
-
- No search results
-
- <% end %>
+
+ <% if @query_terms.present? && @search_results.none? %>
+
+ No search results
+
+ <% end %>
-
- <%= render partial: "searches/result", collection: @search_results %>
-
-
+
+ <%= render partial: "searches/result", collection: @search_results %>
+
+
-
-
+
+
+<% end %>
diff --git a/app/views/shared/_bar.html.erb b/app/views/shared/_bar.html.erb
new file mode 100644
index 000000000..aff139fd0
--- /dev/null
+++ b/app/views/shared/_bar.html.erb
@@ -0,0 +1,28 @@
+<%= tag.div \
+ class: "terminal full-width flex flex-column justify-end",
+ data: {
+ controller: "bar",
+ bar_dialog_outlet: "#bar-modal",
+ bar_search_url_value: search_path,
+ bar_search_turbo_frame_name_value: "search",
+ bar_ask_url_value: conversation_path,
+ bar_ask_turbo_frame_name_value: "conversation",
+ action: "
+ keydown.meta+k@document->bar#search:prevent keydown.ctrl+k@document->bar#search:prevent
+ keydown.meta+a@document->bar#ask:prevent keydown.ctrl+a@document->bar#ask:prevent"
+ } do %>
+
+ Search [<%= hotkey_label(["ctrl", "K"]) %>] or Ask [<%= hotkey_label(["ctrl", "A"]) %>]
+
+
+ <%= tag.dialog \
+ id: "bar-modal",
+ class: "bar__modal panel shadow",
+ data: {
+ controller: "dialog",
+ dialog_target: "dialog",
+ dialog_modal_value: "true",
+ action: "keydown.esc->dialog#close click@document->dialog#closeOnClickOutside" } do %>
+ <%= turbo_frame_tag nil, data: { bar_target: "modalTurboFrame" }, target: "_top" %>
+ <% end %>
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index c447b1203..6d55b04e5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -111,7 +111,7 @@ Rails.application.routes.draw do
resources :commands
- resource :conversation, only: %i[ show ] do
+ resource :conversation, only: %i[ show create ] do
scope module: :conversations do
resources :messages, only: %i[ index create ]
end