[Cases][AttachmentV2] Migrate persistable state part 2 - ML and AIOps charts#262597
Conversation
38ce0f3 to
71cec09
Compare
|
|
||
| return persistableBuilder.build(); | ||
|
|
||
| default: |
There was a problem hiding this comment.
🟡 Medium comment/comment.tsx:220
Removing the AttachmentType.persistableState case causes persistable state attachments to silently return [] instead of rendering. When isLegacyAttachmentRequest(attachment) is true for a persistable state attachment, the switch falls through to default and produces an empty array, hiding the attachment from users.
🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/platform/plugins/shared/cases/public/components/user_actions/comment/comment.tsx around line 220:
Removing the `AttachmentType.persistableState` case causes persistable state attachments to silently return `[]` instead of rendering. When `isLegacyAttachmentRequest(attachment)` is true for a persistable state attachment, the switch falls through to `default` and produces an empty array, hiding the attachment from users.
Evidence trail:
- `x-pack/platform/plugins/shared/cases/common/constants/attachments.ts` lines 37-44: `LEGACY_ATTACHMENT_TYPES` includes `LEGACY_PERSISTABLE_STATE_TYPE`
- `x-pack/platform/plugins/shared/cases/common/utils/attachments/v1_type_guards.ts` lines 36-40: `isLegacyAttachmentRequest()` checks if type is in `LEGACY_ATTACHMENT_TYPES`
- `x-pack/platform/plugins/shared/cases/public/components/user_actions/comment/comment.tsx` lines 179-221 (REVIEWED_COMMIT): switch statement inside `if (isLegacyAttachmentRequest(attachment))` block ends with `default: return [];` - missing `persistableState` case
- git_diff base=MERGE_BASE head=REVIEWED_COMMIT path=comment.tsx: shows `case AttachmentType.persistableState:` was removed
71cec09 to
743c4f3
Compare
|
Pinging @elastic/kibana-cases (Team:Cases) |
There was a problem hiding this comment.
🟢 Low comment/comment.tsx:67
If comment.type === AttachmentType.persistableState, the deleted persistableStateAttachmentTypeRegistry branch is no longer executed, so getDeleteLabelTitle returns the generic ${i18n.REMOVED_FIELD} ${i18n.COMMENT.toLowerCase()} label instead of the registry-specific label that getDeleteLabelFromRegistry would have provided. Since persistableState is in LEGACY_ATTACHMENT_TYPES, isLegacyAttachmentRequest(comment) returns true, but the removed persistableState case means the code falls through to the final return statement.
if (isUnifiedReferenceAttachmentRequest(comment)) {
return getDeleteLabelFromRegistry({
caseData,
registry: unifiedAttachmentTypeRegistry,
getId: () => toUnifiedAttachmentType(comment.type, owner),
getAttachmentProps: () => ({
attachmentId: comment.attachmentId,
metadata: comment.metadata,
}),
});
}
+ if (comment.type === AttachmentType.persistableState) {
+ return `${i18n.REMOVED_FIELD} ${i18n.ATTACHMENT.toLowerCase()}`;
+ }
+
return `${i18n.REMOVED_FIELD} ${i18n.COMMENT.toLowerCase()}`;🤖 Copy this AI Prompt to have your agent fix this:
In file x-pack/platform/plugins/shared/cases/public/components/user_actions/comment/comment.tsx around lines 67-80:
If `comment.type === AttachmentType.persistableState`, the deleted `persistableStateAttachmentTypeRegistry` branch is no longer executed, so `getDeleteLabelTitle` returns the generic `${i18n.REMOVED_FIELD} ${i18n.COMMENT.toLowerCase()}` label instead of the registry-specific label that `getDeleteLabelFromRegistry` would have provided. Since `persistableState` is in `LEGACY_ATTACHMENT_TYPES`, `isLegacyAttachmentRequest(comment)` returns `true`, but the removed `persistableState` case means the code falls through to the final return statement.
Evidence trail:
- Diff at REVIEWED_COMMIT shows removal of `persistableState` branch from `getDeleteLabelTitle` (lines 63-75 removed in diff)
- `x-pack/platform/plugins/shared/cases/common/constants/attachments.ts` lines 27, 37-44: `LEGACY_PERSISTABLE_STATE_TYPE = 'persistableState'` is in `LEGACY_ATTACHMENT_TYPES`
- `x-pack/platform/plugins/shared/cases/common/utils/attachments/v1_type_guards.ts` lines 36-41: `isLegacyAttachmentRequest` returns true for types in `LEGACY_ATTACHMENT_TYPES`
- `x-pack/platform/plugins/shared/cases/common/utils/attachments/v2_type_guards.ts` lines 29-33: `isUnifiedReferenceAttachmentRequest` checks for `'attachmentId' in context`
- `x-pack/platform/plugins/shared/cases/common/types/domain/attachment/v1.ts` lines 301-306: `PersistableStateAttachmentPayloadRt` has `persistableStateAttachmentTypeId` and `persistableStateAttachmentState`, not `attachmentId`
743c4f3 to
ff01442
Compare
Catch flakiness early (recommended)Recommended before merge: run the flaky test runner against this PR to catch flakiness early. Trigger a run with the Flaky Test Runner UI or post this comment on the PR: This check is experimental. Share your feedback in the #appex-qa channel. Posted via Macroscope — Flaky Test Runner nudge |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
|
Flaky Test Runner Stats🟠 Some tests failed. - kibana-flaky-test-suite-runner#11644[✅] x-pack/platform/test/cases_api_integration/security_and_spaces/config_basic.ts: 25/25 tests passed. |
| ), | ||
| type: attachmentTypeByEmbeddableType[embeddableType], | ||
| data: { | ||
| state: JSON.parse(JSON.stringify(persistableStateAttachmentState)), |
There was a problem hiding this comment.
nit: can we consider structuredClone here?
* main: (114 commits) Fix observability_ai_assistant_tool_call EBT error when connector is an inference endpoint (elastic#263334) init on install (elastic#263732) [One Workflow] fail-fast TaskRecovery for interrupted runs (elastic#261275) [Entity Store] Reset state error after successful task run (elastic#263087) [api-docs] 2026-04-19 Daily api_docs build (elastic#264280) [UII] Fix integration card row height calculation (elastic#264212) [scout] migrate FTR logstash api tests (elastic#262953) [StorageIndexAdapter] Set auto_expand_replicas to fix yellow health on single-node ES clusters (elastic#263096) [api-docs] 2026-04-18 Daily api_docs build (elastic#264260) [Scout] Update test config manifests (elastic#264257) [Security Solution][Detection Engine] enables AI rule creation feature flag (elastic#264036) [dashboards as code] only validate id on PUT route when creating new dashboard (elastic#264161) chore(NA): bump version to 9.5.0 (elastic#262165) skip failing test suite (elastic#263649) skip failing test suite (elastic#264236) [Discover] Convert remaining Enzyme tests to RTL (elastic#259676) auto-implement: Labels in model endpoints table of the model details flyout look misaligned (elastic#263770) [ci] Promote ES docker image after verification (elastic#263890) [Observability:Onboarding] Remove suppress global announcements that was breaking ensemble tests (elastic#264169) [Cases][AttachmentV2] Migrate persistable state part 2 - ML and AIOps charts (elastic#262597) ...
Summary
Dependecy: #261407 to be merged first
This PR migrates the remaining persistable state attachments to the unified attachment registry. Case attachment type constants are moved to cases plugin, and a naming conversion is added to keep type names follow the same convention.
Feature flag: xpack.cases.attachments.enabled: true (restart kibana after turning the flag on/off)
Key changes per plugin:
Cases:
Machine learning:
AiOps:
How to test:
Check and confirm the charts can be added and viewed in a case with the feature flag off/on. Note that turning the flag on then off will hide any attachments added when the flag is on, this is expected.
Checklist
release_note:breakinglabel should be applied in these situations.release_note:*label is applied per the guidelinesbackport:*labels.