Replace special value with just not asuming that filters are about open cards by default

This commit is contained in:
Jorge Manrubia
2025-07-24 10:05:53 +02:00
parent 9d0887f6bd
commit dd28e3d1e9
5 changed files with 1907 additions and 18 deletions
+6 -8
View File
@@ -56,7 +56,7 @@ class Command::Ai::Translator
"context": { // omit if empty
"terms": string[], // filter cards by keywords
"indexed_by": "newest" | "oldest" | "latest" | "stalled"
| "closed" | "closing_soon" | "falling_back_soon" | "all", // "all" is a special value only for insight
| "closed" | "closing_soon" | "falling_back_soon",
"assignee_ids": <person>[],
"assignment_status": "unassigned",
"card_ids": <card_id>[],
@@ -157,10 +157,8 @@ class Command::Ai::Translator
* Getting insight about data: how things are progressing, blockers, highlights, etc.
* Summarize information
* Check what a person has done
- If the /insight commands needs to query the data to extract insight, and there is no suitable filter:
* If the data should include completed cards too, use the `indexed_by` filter with `all` (special value only for /insight).
* When asking for people activity, use `indexed_by: "all" unless a explicit filter is requested.
* If not, use `indexed_by` with `latest`.
- If the /insight commands needs to query the data to extract insight, and there is no suitable filter,
use the `indexed_by` filter with `latest`.
- The `/insight` command is used to get insight about the system. It takes a free text query and responds with a textual
response.
- The /insight command can be combined with filters if those help to create a better context for the query.
@@ -303,8 +301,8 @@ class Command::Ai::Translator
#### Getting insight
- most commented cards { context: { indexed_by: "all" }, commands: ["/insight most commented cards"] }
- what has mike done { context: { indexed_by: "all" }, commands: ["/insight what has mike done"] }
- most commented cards { context: { indexed_by: "latest" }, commands: ["/insight most commented cards"] }
- what has mike done { context: { indexed_by: "latest" }, commands: ["/insight what has mike done"] }
- summarize cards completed by mike { context: { closer_ids: ["mike"] }, commands: ["/insight summarize"] }
### Filters and commands combined
@@ -313,7 +311,7 @@ class Command::Ai::Translator
- assign john to the current #design cards and tag them with #v2 → { context: { tag_ids: ["design"] }, commands: ["/assign john", "/tag #v2"] }
- close cards assigned to mike and assign them to roger { context: {assignee_ids: ["mike"]}, commands: ["/close", "/assign roger"] }
- summarize the cards assigned to jz { context: { assignee_ids: ["jz"] }, commands: ["/insight summarize"] }
- summarize the work that ann has done recently { context: { indexed_by: ["all"] }, commands: ["/insight summarize the work that ann has done recently"] }
- summarize the work that ann has done recently { context: { indexed_by: ["latest"] }, commands: ["/insight summarize the work that ann has done recently"] }
PROMPT
end
-3
View File
@@ -70,9 +70,6 @@ class Command::Parser::Context
private
attr_reader :controller, :action, :params
MAX_CARDS = 20
MAX_CLOSED_CARDS = 10
def viewing_card_perma?
controller == "cards" && action == "show"
end
-6
View File
@@ -20,7 +20,6 @@ class Filter < ApplicationRecord
@cards ||= begin
result = creator.accessible_cards.indexed_by(indexed_by)
result = result.where(id: card_ids) if card_ids.present?
result = result.open unless include_closed_cards?
result = result.by_engagement_status(engagement_status) if engagement_status.present?
result = result.unassigned if assignment_status.unassigned?
result = result.assigned_to(assignees.ids) if assignees.present?
@@ -58,9 +57,4 @@ class Filter < ApplicationRecord
def cache_key
ActiveSupport::Cache.expand_cache_key collections.cache_key_with_version, super
end
private
def include_closed_cards?
indexed_by.closed? || closure_window || closers.present? || card_ids.present? || indexed_by.all?
end
end
+1 -1
View File
@@ -171,7 +171,7 @@ class Command::Ai::TranslatorTest < ActionDispatch::IntegrationTest
assert_command({ context: { assignee_ids: ["jz"] }, commands: [ "/insight cards where mike has commented" ] }, "cards where mike has commented assigned to jz")
assert_command({ commands: [ "/insight summarize this" ] }, "summarize this")
assert_command({ commands: [ "/insight are there blockers here?" ] }, "are there blockers here?")
assert_command({ context: { indexed_by: "all" }, commands: [ "/insight stuff that jz has done lately" ] }, "stuff that jz has done lately")
assert_command({ context: { indexed_by: "latest" }, commands: [ "/insight stuff that jz has done lately" ] }, "stuff that jz has done lately")
end
test "combine commands and filters" do
File diff suppressed because it is too large Load Diff