diff --git a/Gemfile.lock b/Gemfile.lock index 8fad5375c..ae7553c8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/basecamp/actiontext-lexical - revision: 38e8d4e5781667b7d1c17eaa5cca503bbc63ee67 + revision: 70ba099446c8a033c06c2bde9c5e70b7f983e60b specs: actiontext-lexical (0.1.0) rails (>= 8.0.2) @@ -444,7 +444,7 @@ GEM rainbow (3.1.1) rake (13.3.0) rb_sys (0.9.106) - rdoc (6.14.1) + rdoc (6.14.2) erb psych (>= 4.0.0) redcarpet (3.6.1) diff --git a/app/javascript/controllers/terminal_controller.js b/app/javascript/controllers/terminal_controller.js index aa857479b..35681f97c 100644 --- a/app/javascript/controllers/terminal_controller.js +++ b/app/javascript/controllers/terminal_controller.js @@ -162,13 +162,15 @@ export default class extends Controller { this.waitingForConfirmationValue = true } - #showConfirmationPrompt(confirmationPrompt) { + async #showConfirmationPrompt(confirmationPrompt) { if (isMultiLineString(confirmationPrompt)) { this.#showOutput(confirmationPrompt) this.inputTarget.value = `Apply these changes? [Y/n] ` } else { this.inputTarget.value = `${confirmationPrompt}? [Y/n] ` } + + await nextFrame() } #handleConfirmationKey(key) { @@ -180,16 +182,17 @@ export default class extends Controller { } } - #submitWithConfirmation() { + async #submitWithConfirmation() { this.inputTarget.value = this.originalInputValue this.confirmationTarget.value = "confirmed" this.#hideOutput() + + await nextFrame() this.#submitCommand() } #submitCommand() { this.formTarget.requestSubmit() - this.#reset() } #showOutput(markdown) { diff --git a/app/models/command/ai/parser.rb b/app/models/command/ai/parser.rb index 59014f900..c2e1db3b3 100644 --- a/app/models/command/ai/parser.rb +++ b/app/models/command/ai/parser.rb @@ -30,7 +30,7 @@ class Command::Ai::Parser commands.unshift Command::VisitUrl.new(user: user, url: query_context.url, context: resolved_context) end - Command::Composite.new(title: query, commands: commands, user: user, line: normalized_query, context: resolved_context) + Command::Composite.new(title: query, commands: commands, user: user, line: query, context: resolved_context) end def commands_from_query(normalized_query, context) diff --git a/app/models/command/parser.rb b/app/models/command/parser.rb index d383a8e27..075162964 100644 --- a/app/models/command/parser.rb +++ b/app/models/command/parser.rb @@ -37,9 +37,7 @@ class Command::Parser when /^#/ Command::FilterByTag.new(tag_title: tag_title_from(string), params: filter.as_params) when /^@/ - Command::GoToUser.new(user_id: context.find_user(command_name)&.id) - when "/user" - Command::GoToUser.new(user_id: context.find_user(combined_arguments)&.id) + Command::GoToUser.new(user_id: context.find_user(string)&.id) when "/assign", "/assignto" Command::Assign.new(assignee_ids: assignees_from(command_arguments).collect(&:id), card_ids: cards.ids) when "/clear" @@ -64,11 +62,22 @@ class Command::Parser Command::VisitUrl.new(url: command_arguments.first) when "/tag" Command::Tag.new(tag_title: tag_title_from(combined_arguments), card_ids: cards.ids) + when /^gid:\/\// + parse_gid command_name else parse_free_string(string) end end + def parse_gid(command_name) + case record = GlobalID::Locator.locate(command_name) + when Tag + Command::FilterByTag.new(tag_title: record.title, params: filter.as_params) + when User + Command::GoToUser.new(user_id: record.id) + end + end + def assignees_from(strings) Array(strings).filter_map do |string| context.find_user(string) diff --git a/app/models/tag/attachable.rb b/app/models/tag/attachable.rb index 7b0a960e2..37d95b2dd 100644 --- a/app/models/tag/attachable.rb +++ b/app/models/tag/attachable.rb @@ -3,9 +3,9 @@ module Tag::Attachable included do include ActionText::Attachable - end - def attachable_plain_text_representation(...) - "##{title}" + def attachable_plain_text_representation(...) + "##{title}" + end end end diff --git a/app/models/user/attachable.rb b/app/models/user/attachable.rb index c1505535e..2ffde99c3 100644 --- a/app/models/user/attachable.rb +++ b/app/models/user/attachable.rb @@ -3,9 +3,9 @@ module User::Attachable included do include ActionText::Attachable - end - def attachable_plain_text_representation(...) - "@#{first_name.downcase}" + def attachable_plain_text_representation(...) + "@#{first_name.downcase}" + end end end diff --git a/config/initializers/tenanting/active_storage.rb b/config/initializers/tenanting/active_storage.rb index 278b92de8..f57cdc304 100644 --- a/config/initializers/tenanting/active_storage.rb +++ b/config/initializers/tenanting/active_storage.rb @@ -14,6 +14,6 @@ module ActiveStorageControllerExtensions end end -Rails.application.config.after_initialize do +Rails.application.config.to_prepare do ActiveStorage::BaseController.include ActiveStorageControllerExtensions end diff --git a/test/models/command/ai/parser_test.rb b/test/models/command/ai/parser_test.rb index 7416d6912..821edd965 100644 --- a/test/models/command/ai/parser_test.rb +++ b/test/models/command/ai/parser_test.rb @@ -4,10 +4,11 @@ class Command::Ai::ParserTest < ActionDispatch::IntegrationTest include CommandTestHelper, VcrTestHelper test "parse command strings into a composite command containing the individual commands" do - result = parse_command "assign @kevin and close" + command = parse_command "assign @kevin and close" - assert_instance_of Command::Composite, result - commands = result.commands + assert_equal "assign @kevin and close", command.line + assert_instance_of Command::Composite, command + commands = command.commands assert_instance_of Command::Assign, commands.first assert_instance_of Command::Close, commands.last