Merge branch 'main' into jz-7-3-25-pm

* main:
  Change Active Storage account slug extension to a to_prepare block
  dep: bump actiontext-lexical for previewable attachment fix
  Add assertion for composite command line
  Remove trace
  restore the right command
  Update action text
  The prompt confirmation system wasn't really working after moving to lexical
  Parse commands where it's just a gid properly
  Move inside concerns or the override won't work
This commit is contained in:
Jason Zimdars
2025-07-03 19:24:56 -05:00
8 changed files with 32 additions and 19 deletions
+2 -2
View File
@@ -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)
@@ -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) {
+1 -1
View File
@@ -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)
+12 -3
View File
@@ -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)
+3 -3
View File
@@ -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
+3 -3
View File
@@ -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
@@ -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
+4 -3
View File
@@ -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