Skip to content

Commit 5cfede6

Browse files
Apollon77claude
andauthored
fix(model): render DataModelPath via squash presentation instead of nested Diagnostic.squash (#3673)
The previous `[Diagnostic.value]` getter returned `Diagnostic.squash(result)` — a wrapper diagnostic. The log formatter's `valueFor` only does a single-level unwrap, so the squash wrapper made it past extraction but its inner items array did not. The renderer's `case "squash"` then fell through to `serialize(...)`, emitting `"{}"` for any DataModelPath wrapped in `Diagnostic.strong(...)`. This broke Write/Invoke client diagnostics introduced earlier on this branch. Fix by setting `[Diagnostic.presentation] = "squash"` directly on DataModelPath and returning the items array from `[Diagnostic.value]`. The renderer now unwraps the items array on the first pass and concatenates segments correctly. Adds a render-level regression test that exercises the formatter chain. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ee67966 commit 5cfede6

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

packages/model/src/common/DataModelPath.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ export class DataModelPath implements Diagnostic {
4747
return [this.id];
4848
}
4949

50-
get [Diagnostic.value](): Diagnostic {
50+
get [Diagnostic.presentation](): Diagnostic.Presentation {
51+
return "squash";
52+
}
53+
54+
get [Diagnostic.value](): unknown {
5155
const result = Array<unknown>();
5256
this.#appendDiagnostic(result);
53-
return Diagnostic.squash(result);
57+
return result;
5458
}
5559

5660
#appendDiagnostic(result: unknown[]) {

packages/protocol/test/common/ExpandedPathTest.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { ExpandedPath } from "#common/ExpandedPath.js";
8+
import { Diagnostic, LogFormat } from "@matter/general";
89
import { AttributeId, ClusterId, CommandId, EndpointNumber, EventId } from "@matter/types";
910

1011
describe("ExpandedPath", () => {
@@ -112,4 +113,22 @@ describe("ExpandedPath", () => {
112113
expect(path.toString()).equal("0.onOff.on");
113114
});
114115
});
116+
117+
describe("Diagnostic rendering", () => {
118+
// Ensures DataModelPath emitted by ExpandedPath renders properly when wrapped in Diagnostic helpers
119+
// (i.e. not as "{}" — see https://github.com/matter-js/matter.js/pull/3664)
120+
it("renders attribute path inline via plaintext formatter", () => {
121+
const path = ExpandedPath({
122+
path: {
123+
endpointId: EndpointNumber(0),
124+
clusterId: ClusterId(0x6),
125+
attributeId: AttributeId(0x0),
126+
},
127+
});
128+
129+
const text = LogFormat.formats.plain(Diagnostic.message({ values: [Diagnostic.strong(path), " = true"] }));
130+
131+
expect(text).contains("0.onOff.state.onOff = true");
132+
});
133+
});
115134
});

0 commit comments

Comments
 (0)