feat(conversations): trim search payload meta

This commit is contained in:
2026-06-07 03:57:45 +08:00
parent 41bdec333b
commit 7892799802
3 changed files with 12 additions and 6 deletions
+8 -4
View File
@@ -49,11 +49,11 @@ Hermes task landing checklist:
## Current Baseline
- Current tracking checkpoint: 2026-06-07 P3.61 conversation search sender-name parity, prepared as `feat(conversations): align search sender names`.
- Latest implementation checkpoint: this checkpoint, prepared as `feat(conversations): align search sender names`.
- Latest documentation/tooling checkpoint: this tracker update records Chatwoot search model serializer `sender_name message.sender.name if message.sender` behavior for conversation search results. No route artifacts change.
- Current tracking checkpoint: 2026-06-07 P3.62 conversation search payload-field parity, prepared as `feat(conversations): trim search payload meta`.
- Latest implementation checkpoint: this checkpoint, prepared as `feat(conversations): trim search payload meta`.
- Latest documentation/tooling checkpoint: this tracker update records that Chatwoot `conversations/search` renders each payload item through the search `_conversation` partial without the normal conversation `meta` object. No route artifacts change.
- Plan landing status: complete for the current known Hermes plans and user-confirmed scope. Future work should update this file directly instead of opening a parallel tracker.
- Worktree status at this implementation checkpoint: conversation search messages now serialize `sender_name` from persisted contact/user senders when Chatwoot's search model serializer would expose `message.sender.name`, while retaining P3.60 numeric `message_type` parity. P3.59 search finder payload parity, P3.58 index finder parity, P3.57/P3.56/P3.55 conversation meta parity, P3.54 unread-count parity, P5.8b contact import DataImportJob parity, P3.53 first-response distribution parity, and prior report/profile/channel/contact checkpoints remain implemented. Live API/browser/enterprise smoke still needs the full PostgreSQL/Redis/Meilisearch/GoChat/Vite/Chrome stack.
- Worktree status at this implementation checkpoint: conversation search payload items now omit the normal conversation `meta` object and only return the fields in Chatwoot's search `_conversation` partial, while retaining P3.61 sender-name and P3.60 numeric message-type parity. P3.59 search finder payload parity, P3.58 index finder parity, P3.57/P3.56/P3.55 conversation meta parity, P3.54 unread-count parity, P5.8b contact import DataImportJob parity, P3.53 first-response distribution parity, and prior report/profile/channel/contact checkpoints remain implemented. Live API/browser/enterprise smoke still needs the full PostgreSQL/Redis/Meilisearch/GoChat/Vite/Chrome stack.
- Next executable implementation checkpoint: continue Phase 2/3 drift audit for deeper report data-source/metric-builder drift or the next reused-frontend mismatch, or run B12 live smoke when the full PostgreSQL/Redis/Meilisearch/GoChat/Vite/Chrome stack is available. Re-run Phase 6 placeholder audit after future route/smoke changes.
- `go test ./...` passes when run outside the restricted socket sandbox for the latest implementation baseline; the latest docs/tooling checkpoint verified `scripts/parity_frontend_smoke.sh --check` with workspace-local temp/cache dirs after `/tmp` was full.
- Route dump succeeds with `967` registered routes after profile MFA route tracking.
@@ -156,6 +156,7 @@ This table is the shortest authoritative handoff view. If an older lower section
| Priority | Workstream | Current state | Next checkpoint | Commit close rule |
| --- | --- | --- | --- | --- |
| 0 | P3.62 conversation search payload-field parity | Implemented for reused dashboard conversation search results: GoChat now follows `conversations/search.json.jbuilder` plus the search `_conversation` partial by omitting the normal conversation `meta` object from each search payload item. | Keep in Review; reopen from B12 conversation search smoke or fresh reference evidence for message ordering, sender polymorphic types beyond Contact/User, or additional search model serializer fields. | Focused conversation search handler test, full `go test ./...`, and `git diff --check` must pass. No route artifacts change. |
| 0 | P3.61 conversation search sender-name parity | Implemented for reused dashboard conversation search results: GoChat now follows inspected `api/v1/models/_conversation.json.jbuilder` by emitting `sender_name` from `message.sender.name` for persisted contact/user senders in search result messages. | Keep in Review; reopen from B12 conversation search smoke or fresh reference evidence for message ordering, sender polymorphic types beyond Contact/User, or additional search model serializer fields. | Focused conversation search handler test, full `go test ./...`, and `git diff --check` must pass. No route artifacts change. |
| 0 | P3.60 conversation search message-type parity | Implemented for reused dashboard conversation search results: GoChat now follows inspected `api/v1/models/_conversation.json.jbuilder` by serializing each search result message `message_type` as Chatwoot enum integers (`incoming=0`, `outgoing=1`, `activity=2`, `template=3`) instead of local string values. | Keep in Review; reopen from B12 conversation search smoke or fresh reference evidence for message ordering or additional search model serializer fields. | Focused conversation search handler test, full `go test ./...`, and `git diff --check` must pass. No route artifacts change. |
| 0 | P3.59 conversation search finder parity | Implemented for reused dashboard conversation search calls: GET `/conversations/search` now follows inspected Chatwoot `ConversationsController#search`, `ConversationFinder#perform`, and `search.json.jbuilder`; it uses the finder filters/counts, accepts missing `q`, returns root `{ meta, payload }`, omits `assigned_count`, and emits search-specific contact/inbox/message payloads. | Keep in Review; reopen from B12 conversation search smoke or fresh reference evidence for exact model search serializer drift, PostgreSQL `ILIKE` case-folding drift, or duplicate message join count drift. | Focused conversation search handler tests, full `go test ./...`, and `git diff --check` must pass. No route artifacts change. |
@@ -224,6 +225,7 @@ These rows are the executable development plan from this point forward. A checkp
| ID | Owner files | Reference files | Work to land | Exit gate |
| --- | --- | --- | --- | --- |
| P3.62 conversation search payload-field parity | `internal/handler/api/v1/conversation_serializer.go`, conversation search handler tests | `reference/chatwoot/app/views/api/v1/accounts/conversations/search.json.jbuilder`, `reference/chatwoot/app/views/api/v1/models/_conversation.json.jbuilder` | Conversation search payload items now omit the normal list/show `meta` object, matching the dedicated search partial fields: `id`, `uuid`, `created_at`, `contact`, `inbox`, `messages`, and `account_id`. | Review by `feat(conversations): trim search payload meta`; focused search handler tests assert the root `meta` still exists but each payload item has no `meta`; full `go test ./...` and `git diff --check` must pass. No route artifacts change. |
| P3.61 conversation search sender-name parity | `internal/handler/api/v1/conversation_serializer.go`, conversation search handler tests | `reference/chatwoot/app/views/api/v1/models/_conversation.json.jbuilder`, `reference/chatwoot/app/views/api/v1/accounts/conversations/search.json.jbuilder` | Conversation search result messages now serialize `sender_name` when the persisted sender can be resolved, matching `json.sender_name message.sender.name if message.sender` for contact and user senders. | Review by `feat(conversations): align search sender names`; focused search handler tests assert contact and user `sender_name`; full `go test ./...` and `git diff --check` must pass. No route artifacts change. |
| P3.60 conversation search message-type parity | `internal/handler/api/v1/conversation_serializer.go`, conversation search handler tests | `reference/chatwoot/app/views/api/v1/models/_conversation.json.jbuilder`, `reference/chatwoot/app/views/api/v1/accounts/conversations/search.json.jbuilder` | Conversation search result messages now serialize `message_type` using Chatwoot `message_type_before_type_cast` integer semantics, sharing the existing message-type mapping used by normal message serializers. | Review by `feat(conversations): align search message types`; focused search handler tests assert numeric `message_type`; full `go test ./...` and `git diff --check` must pass. No route artifacts change. |
| P3.59 conversation search finder parity | `internal/handler/api/v1/conversation_handler.go`, `internal/handler/api/v1/conversation_serializer.go`, `internal/service/conversation_service.go`, `internal/repository/conversation_repo.go`, conversation search handler tests | `reference/chatwoot/app/controllers/api/v1/accounts/conversations_controller.rb#search`, `reference/chatwoot/app/finders/conversation_finder.rb`, `reference/chatwoot/app/views/api/v1/accounts/conversations/search.json.jbuilder`, `reference/chatwoot/app/views/api/v1/models/_conversation.json.jbuilder`, `reference/chatwoot/app/javascript/dashboard/api/inbox/conversation.js` | GET `/api/v1/accounts/:account_id/conversations/search` now uses the same finder path as index/search in Chatwoot, accepts missing `q`, preserves query/status skip semantics, and returns the root search payload shape `{ meta: { mine_count, unassigned_count, all_count }, payload }` with search-specific contact/inbox/messages fields instead of the local list/data envelope. | Review by `feat(conversations): align search finder payload`; focused search handler tests cover root payload shape, omitted `assigned_count`, missing-`q` behavior, all-status query search, and search serializer fields; full `go test ./...` and `git diff --check` must pass. No route artifacts change. |
@@ -310,6 +312,7 @@ This ledger records the committed parity checkpoints that future slices should b
| Commit | Scope | Verification summary | Follow-up state |
| --- | --- | --- | --- |
| `feat(conversations): trim search payload meta` | Advances P3.62 with Chatwoot conversation search payload-field parity. Search result payload items now use only the dedicated search `_conversation` partial fields and no longer include the normal list/show `meta` object, while preserving the root search `meta` counts and P3.61/P3.60 message fields. | `go test ./internal/handler/api/v1 -run 'ConversationCrudTestSuite/TestSearch' -count=1`; `go test ./internal/repository ./internal/service ./internal/handler/api/v1 -run 'ConversationRepo_(GetMeta\|ListForFinder)\|Conversation.*(Meta\|List\|Search)\|ConversationCrudTestSuite/Test(Search\|List)' -count=1`; `go test ./...`; `git diff --check`. No route artifacts change. | Move P3.62 to Review; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. |
| `feat(conversations): align search sender names` | Advances P3.61 with Chatwoot conversation search model serializer parity. Search result messages now resolve persisted contact/user senders and emit `sender_name` using the same `message.sender.name if message.sender` behavior as the reference `_conversation` Jbuilder, while preserving P3.60 numeric `message_type` and P3.59 root search payload behavior. | `go test ./internal/handler/api/v1 -run 'ConversationCrudTestSuite/TestSearch' -count=1`; `go test ./internal/repository ./internal/service ./internal/handler/api/v1 -run 'ConversationRepo_(GetMeta\|ListForFinder)\|Conversation.*(Meta\|List\|Search)\|ConversationCrudTestSuite/Test(Search\|List)' -count=1`; `go test ./...`; `git diff --check`. No route artifacts change. | Move P3.61 to Review; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. |
| `feat(conversations): align search message types` | Advances P3.60 with Chatwoot conversation search message serializer parity. Search result messages now emit integer `message_type` values matching `message_type_before_type_cast`, instead of GoChat string enums, while preserving the P3.59 root search payload and finder behavior. | `go test ./internal/handler/api/v1 -run 'ConversationCrudTestSuite/TestSearch' -count=1`; `go test ./internal/repository ./internal/service ./internal/handler/api/v1 -run 'ConversationRepo_(GetMeta\|ListForFinder)\|Conversation.*(Meta\|List\|Search)\|ConversationCrudTestSuite/Test(Search\|List)' -count=1`; `go test ./...`; `git diff --check`. No route artifacts change. | Move P3.60 to Review; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. |
| `feat(conversations): align search finder payload` | Advances P3.59 with Chatwoot conversation search finder parity. GET `/conversations/search` now calls the same ConversationFinder-style service path as index, accepts missing `q`, preserves query/status-skip semantics, and returns the root search Jbuilder payload with `mine_count`, `unassigned_count`, `all_count`, and search-specific conversation contact/inbox/message fields. | `go test ./internal/handler/api/v1 -run 'ConversationCrudTestSuite/TestSearch' -count=1`; `go test ./internal/repository ./internal/service ./internal/handler/api/v1 -run 'ConversationRepo_(GetMeta\|ListForFinder)\|Conversation.*(Meta\|List\|Search)\|ConversationCrudTestSuite/Test(Search\|List)' -count=1`; `go test ./...`; `git diff --check`. No route artifacts change. | Move P3.59 to Review; continue Phase 2/3 drift audit, Phase 6 placeholder audit, or B12 live smoke. |
@@ -2625,3 +2628,4 @@ Verification milestone gates:
- 2026-06-07: P3.59 conversation search finder checkpoint prepared as `feat(conversations): align search finder payload`; audited Chatwoot `ConversationsController#search`, `ConversationFinder#perform`, `search.json.jbuilder`, `_conversation` search model serializer, and reused dashboard `ConversationApi.search`. GoChat GET `/conversations/search` now uses the finder-style path, accepts missing `q`, keeps query/status-skip behavior, returns root `{ meta, payload }` without `assigned_count` or `data`, and serializes search-specific contact/inbox/messages fields. Focused search/list handler and finder tests passed; full `go test ./...` and `git diff --check` passed. No route artifacts change.
- 2026-06-07: P3.60 conversation search message-type checkpoint prepared as `feat(conversations): align search message types`; audited Chatwoot search `_conversation` model serializer and its `message_type_before_type_cast` field. GoChat conversation search result messages now emit integer message types (`incoming=0`, `outgoing=1`, `activity=2`, `template=3`) instead of local string enums. Focused search handler tests passed; full `go test ./...` and `git diff --check` passed. No route artifacts change.
- 2026-06-07: P3.61 conversation search sender-name checkpoint prepared as `feat(conversations): align search sender names`; audited Chatwoot search `_conversation` model serializer and its `json.sender_name message.sender.name if message.sender` field. GoChat conversation search result messages now resolve persisted contact/user senders and emit `sender_name` alongside the existing numeric `message_type` payload. Focused search handler tests passed; full `go test ./...` and `git diff --check` passed. No route artifacts change.
- 2026-06-07: P3.62 conversation search payload-field checkpoint prepared as `feat(conversations): trim search payload meta`; audited Chatwoot `conversations/search.json.jbuilder` and the dedicated search `_conversation` partial. GoChat search payload items now omit the normal conversation `meta` object and keep only the search partial fields while preserving root search `meta` counts. Focused search handler tests passed; full `go test ./...` and `git diff --check` passed. No route artifacts change.
@@ -931,6 +931,10 @@ func (s *ConversationCrudTestSuite) TestSearch_Success() {
s.Require().NoError(json.Unmarshal(w.Body.Bytes(), &raw))
rawMeta := raw["meta"].(map[string]any)
assert.NotContains(s.T(), rawMeta, "assigned_count")
rawPayload := raw["payload"].([]any)
s.Require().NotEmpty(rawPayload)
rawConversation := rawPayload[0].(map[string]any)
assert.NotContains(s.T(), rawConversation, "meta")
assert.Equal(s.T(), int64(2), resp.Meta.AllCount)
assert.Equal(s.T(), int64(2), resp.Meta.UnassignedCount)
assert.Len(s.T(), resp.Payload, 2)
@@ -87,7 +87,6 @@ type chatwootConversationSearchPayload struct {
Inbox map[string]any `json:"inbox"`
Messages []chatwootConversationSearchMessage `json:"messages"`
AccountID uint `json:"account_id"`
Meta chatwootConversationMeta `json:"meta"`
}
type chatwootConversationSearchMessage struct {
@@ -164,7 +163,6 @@ func serializeConversationSearch(ctx context.Context, db *gorm.DB, conversation
Inbox: map[string]any{"id": conversation.InboxID, "channel_type": conversation.ChannelType},
Messages: []chatwootConversationSearchMessage{},
AccountID: conversation.AccountID,
Meta: serializeConversationMeta(ctx, db, conversation),
}
if db == nil {
return payload