Add prompt for tags too
This commit is contained in:
@@ -146,7 +146,8 @@ class Command::Ai::Translator
|
||||
* ❗ Once you produce a valid context **or** command list, do not add a fallback /search.
|
||||
|
||||
---------------------- RESOLVE COMMAND ARGUMENTS ----------------------
|
||||
* A person can be express by its name or via a global ID URL like gid://fizzy/User/773524000?tenant=37signals.
|
||||
* A person can be expressed by its name or via a global ID URL like gid://fizzy/User/1234?tenant=37signals.
|
||||
* A tag can be expressed by its text or via a global ID URL like gid://fizzy/Tag/5678?tenant=37signals.
|
||||
|
||||
-------------------- COMMAND INTERPRETATION RULES --------------------
|
||||
* /user <Name> → open that person’s profile or activity feed.
|
||||
|
||||
@@ -24,11 +24,12 @@ class Command::Parser
|
||||
ActionText::Content.new(string).to_plain_text
|
||||
end
|
||||
|
||||
private
|
||||
def parse_command(string)
|
||||
rich_text_command = as_plain_text_with_attachable_references(string)
|
||||
plain_text_command = as_plain_text(string)
|
||||
|
||||
Rails.logger.info "COMMANDS: #{rich_text_command} AND #{plain_text_command}"
|
||||
|
||||
parse_plain_text_command(plain_text_command) || parse_rich_text_command(rich_text_command)
|
||||
end
|
||||
|
||||
@@ -36,10 +37,10 @@ class Command::Parser
|
||||
command_name, *_ = string.strip.split(" ")
|
||||
|
||||
case command_name
|
||||
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 /^#/
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -88,7 +89,7 @@ class Command::Parser
|
||||
end
|
||||
|
||||
def tag_title_from(string)
|
||||
string.gsub(/^#/, "")
|
||||
context.find_tag(string)&.title || string.gsub(/^#/, "")
|
||||
end
|
||||
|
||||
def parse_free_string(string)
|
||||
|
||||
@@ -29,11 +29,12 @@ class Command::Parser::Context
|
||||
end
|
||||
|
||||
def find_user(string)
|
||||
string = string.delete_prefix("@")
|
||||
|
||||
if string.starts_with?("gid://")
|
||||
User.find_by_id(GlobalID::Locator.locate(string).id)
|
||||
else
|
||||
string_without_at = string.delete_prefix("@")
|
||||
User.all.find { |user| user.mentionable_handles.include?(string_without_at.downcase) }
|
||||
User.all.find { |user| user.mentionable_handles.include?(string.downcase) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +45,12 @@ class Command::Parser::Context
|
||||
end
|
||||
|
||||
def find_tag(string)
|
||||
Tag.find_by_title(string)
|
||||
string = string.delete_prefix("#")
|
||||
if string.starts_with?("gid://")
|
||||
Tag.find_by_id(GlobalID::Locator.locate(string).id)
|
||||
else
|
||||
Tag.find_by_title(string)
|
||||
end
|
||||
end
|
||||
|
||||
def find_collection(string)
|
||||
|
||||
Reference in New Issue
Block a user