Merge pull request #708 from basecamp/commandline-issues

More prompt fixes
This commit is contained in:
Jorge Manrubia
2025-07-04 00:09:22 +02:00
committed by GitHub
7 changed files with 30 additions and 17 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/basecamp/actiontext-lexical
revision: 38e8d4e5781667b7d1c17eaa5cca503bbc63ee67
revision: 30ed20ed2939b14d92bad325dae4e75b5c4c2181
specs:
actiontext-lexical (0.1.0)
rails (>= 8.0.2)
@@ -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
+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