diff --git a/app/models/command/ai/translator.rb b/app/models/command/ai/translator.rb index 99235068b..b2ab30a77 100644 --- a/app/models/command/ai/translator.rb +++ b/app/models/command/ai/translator.rb @@ -9,7 +9,6 @@ class Command::Ai::Translator def translate(query) response = translate_query_with_llm(query) - Rails.logger.debug "Commands: #{response}" normalize JSON.parse(response) end @@ -92,9 +91,10 @@ class Command::Ai::Translator * Unless you can clearly match the query with a command, pass the expression verbatim to /search to perform a search with it. * When searching for nouns (singular or plural), if they don't refer to a person, favor /search with them instead of using the "terms" filter. + * Respect strictly the order of commands as the appear in the user request. * When using /search, pass the expression to search verbatim, don't interpret it. * "tag with #design": always `/tag #design`. Do NOT create `tag_ids` context. - * "#design cards" or "cards tagged with #design": use `tag_ids`. + * "#design cards" or "cards tagged with #design": use `tag_ids`. Do not use the /tag command in this case. * "Assign cards tagged with #design to jz": filter by `tag_ids`, command `/assign jz`. Do NOT generate `/tag` command. * "close as [reason]" or "close because [reason]": include the reason in the `/close` command, e.g., `/close not now`. * "close": always `/close`, even if no reason is given or no cards are explicitly described. @@ -145,6 +145,8 @@ class Command::Ai::Translator Omit empty arrays or unnecessary properties. At least one property (`context` or `commands`) must exist. + Never include JSON outside of "context" or "commands". + ## Other Strict Instructions: * NEVER add properties based on view descriptions ("card", "list", etc.). diff --git a/app/models/command/parser/context.rb b/app/models/command/parser/context.rb index 0efcf0fa9..a4e8b3e18 100644 --- a/app/models/command/parser/context.rb +++ b/app/models/command/parser/context.rb @@ -12,7 +12,7 @@ class Command::Parser::Context if viewing_card_contents? user.accessible_cards.where id: params[:id] elsif viewing_list_of_cards? - filtered_cards + filter.cards.published else Card.none end @@ -43,11 +43,4 @@ class Command::Parser::Context @action = route[:action] @params = ActionController::Parameters.new(Rack::Utils.parse_nested_query(uri.query).merge(route.except(:controller, :action))) end - - def filtered_cards - open_cards = filter.cards.published.limit(MAX_CARDS) - closed_cards = filter.indexed_by.stalled? || filter.indexed_by.closed? ? Card.none : filter.with(indexed_by: "closed").cards.limit(MAX_CLOSED_CARDS) - Rails.logger.info "CLOSED CARDS: #{closed_cards.collect(&:title)}" - user.accessible_cards.where(id: open_cards.ids + closed_cards.ids) - end end diff --git a/test/controllers/commands_controller_test.rb b/test/controllers/commands_controller_test.rb index ba1b0f460..339be0775 100644 --- a/test/controllers/commands_controller_test.rb +++ b/test/controllers/commands_controller_test.rb @@ -3,6 +3,8 @@ require "test_helper" class CommandsControllerTest < ActionDispatch::IntegrationTest include VcrTestHelper + vcr_record! + setup do sign_in_as :kevin end diff --git a/test/models/command/ai/translator_test.rb b/test/models/command/ai/translator_test.rb index 03dbed8b4..a3e8fd248 100644 --- a/test/models/command/ai/translator_test.rb +++ b/test/models/command/ai/translator_test.rb @@ -49,14 +49,6 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest assert_command({ context: { terms: [ "123" ] } }, "123") # Notice existing cards will be intercepted earlier end - test "getting insight on cards" do - # Card context - assert_command({ commands: [ "/insight summarize" ] }, "summarize", context: :card) - assert_command({ commands: [ "/insight steps to reproduce" ] }, "steps to reproduce", context: :card) - assert_command({ commands: [ "/insight create a table with the main participants and takeaways" ] }, "create a table with the main participants and takeaways", context: :card) - assert_command({ commands: [ "/insight what's the issue here?" ] }, "what's the issue here?", context: :card) - end - test "filter by collections" do assert_command({ context: { collection_ids: [ "writebook" ] } }, "writebook collection") end @@ -74,7 +66,7 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest test "assign cards" do # List context assert_command({ commands: [ "/assign jz" ] }, "assign to jz") - assert_command({ context: { tag_ids: [ "design" ] }, commands: [ "/assign jz" ] }, "assign cards tagged with #design to jz", context: :card) + assert_command({ context: { tag_ids: [ "design" ] }, commands: [ "/assign jz" ] }, "assign cards agged with #design to jz", context: :card) end test "tag cards" do