Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Fix review round 2: name the id in get_ticket, pin that the list is uncut

Guido Boykef630dc840972
diff --git a/app/services/lalabase/tools/get_ticket.rb b/app/services/lalabase/tools/get_ticket.rb
index 3bfd786..d52d033 100644
--- a/app/services/lalabase/tools/get_ticket.rb
+++ b/app/services/lalabase/tools/get_ticket.rb
@@ -18,7 +18,7 @@ module Lalabase
# question about the attached PDF is answered from this payload or not at all.
# A `text_status` per file says whether that text exists, is missing, or was
# never extractable — silence would be answered with a guess. A comment's files
- # are another matter: they come with the comment as name, type and size only
+ # are another matter: they come with the comment as id, name, type and size
# (Tickets::Serializer#post_attachments), uncapped metadata like its author, and
# the description says that their text is not here.
#
@@ -94,8 +94,8 @@ module Lalabase
'none, such as a scanned PDF ("empty"), has not been read out yet or the ' \
'reading failed, so the same file may answer later ("unavailable"), or is ' \
'a type we never read text from ("unsupported"). ' \
- 'A comment lists its own files in attachments too, by name, type and size ' \
- 'only: their text is not here. ' \
+ 'A comment lists its own files in attachments too, by id, name, type and size: ' \
+ 'their text is not here. ' \
'status_functions says what the status means in its project (is_backlog, is_new, ' \
'is_open, is_in_progress, is_completed, is_closed), [] when the project gave it none. ' \
'Long bodies are truncated, the posts and the ticket\'s attachments are capped, ' \
diff --git a/spec/fixtures/mcp_contract.json b/spec/fixtures/mcp_contract.json
index 20ef017..8754627 100644
--- a/spec/fixtures/mcp_contract.json
+++ b/spec/fixtures/mcp_contract.json
@@ -1,9 +1,9 @@
{
"header": {
"regenerate": "RAILS_ENV=test bin/rails mcp:contract",
- "core_commit": "12988a8562ad16f99c9cd7e3c9ad07d9d0b72b00",
+ "core_commit": "fd8bc86139b3a3cf239bd630aef7b47a91f248bf",
"core_dirty": true,
- "contract_sha256": "d02a053ea887a9f409778ef5698d63ed69d01f5f67a2fa8edef684876ce485c5"
+ "contract_sha256": "7df2bef5397ad681a83d23b9a7c86cfd2de851beb7165c14c92754f1c38e7b50"
},
"contract": {
"mcp": {
@@ -235,7 +235,7 @@
},
{
"name": "get_ticket",
- "description": "Fetches a single ticket as JSON: head fields, description, custom attributes and discussion posts (oldest first). Address the ticket either by ticket_id (its UUID) or by number, the \"#187\" users see in the app; a number is unique within one project only. ticket_id wins when both are given. Authorized per-record against the token owner. The ticket's attachments come with the text extracted from each file, so a question about an attached PDF is answered from here; text_status says whether a file has readable text (\"available\"), was read and holds none, such as a scanned PDF (\"empty\"), has not been read out yet or the reading failed, so the same file may answer later (\"unavailable\"), or is a type we never read text from (\"unsupported\"). A comment lists its own files in attachments too, by name, type and size only: their text is not here. status_functions says what the status means in its project (is_backlog, is_new, is_open, is_in_progress, is_completed, is_closed), [] when the project gave it none. Long bodies are truncated, the posts and the ticket's attachments are capped, and attachment download URLs are not included.",
+ "description": "Fetches a single ticket as JSON: head fields, description, custom attributes and discussion posts (oldest first). Address the ticket either by ticket_id (its UUID) or by number, the \"#187\" users see in the app; a number is unique within one project only. ticket_id wins when both are given. Authorized per-record against the token owner. The ticket's attachments come with the text extracted from each file, so a question about an attached PDF is answered from here; text_status says whether a file has readable text (\"available\"), was read and holds none, such as a scanned PDF (\"empty\"), has not been read out yet or the reading failed, so the same file may answer later (\"unavailable\"), or is a type we never read text from (\"unsupported\"). A comment lists its own files in attachments too, by id, name, type and size: their text is not here. status_functions says what the status means in its project (is_backlog, is_new, is_open, is_in_progress, is_completed, is_closed), [] when the project gave it none. Long bodies are truncated, the posts and the ticket's attachments are capped, and attachment download URLs are not included.",
"inputSchema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
diff --git a/spec/requests/api/v1/comment_files_spec.rb b/spec/requests/api/v1/comment_files_spec.rb
index ebce759..89cf7bf 100644
--- a/spec/requests/api/v1/comment_files_spec.rb
+++ b/spec/requests/api/v1/comment_files_spec.rb
@@ -266,6 +266,31 @@ RSpec.describe 'Comment files in the ticket view', :ci_guard, type: :request do
end
end
+ # The list has no cap of its own. Cut without a word it would read like a file
+ # that lost its blob, beside a higher attachments_count. One more than a page of
+ # the ticket's files is the cap it would most likely get by mistake.
+ describe 'a comment with more files than a page of ticket files' do
+ let(:file_count) { Tickets::Reading::MAX_ATTACHMENTS + 1 }
+
+ before do
+ Prosopite.pause do
+ ActsAsTenant.with_tenant(organisation) do
+ (file_count - 1).times { |number| file(comments[:last], "anhang-#{number}.txt", 'text/plain') }
+ end
+ end
+ end
+
+ it 'lists every one of them on REST, as many as it counts' do
+ data = get_json(other, comment_path(:last))['data']
+ expect(data['attachments'].size).to eq(file_count)
+ expect(data['attachments_count']).to eq(file_count)
+ end
+
+ it 'lists every one of them on a page of MCP get_ticket' do
+ expect(listed_on(JSON.parse(mcp_ticket(other))['posts'], :last).size).to eq(file_count)
+ end
+ end
+
# Prosopite watches every example here, and four files on three comments are
# enough for it to speak. This one says what it would only imply: one read of
# each table for a whole page.