fix(tree): from_dict L2 subtitle 旧格式兼容 fallback
旧格式 tree.json 无 card-level L2 subtitle 时,从已构造的 L3 children 聚合 subtitle,避免运行时加载静默丢失 L2 字幕。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -367,6 +368,11 @@ class L1Node:
|
|||||||
state_changes=l2d["card"]["state_changes"],
|
state_changes=l2d["card"]["state_changes"],
|
||||||
subtitle=l2d["card"].get("subtitle", ""),
|
subtitle=l2d["card"].get("subtitle", ""),
|
||||||
)
|
)
|
||||||
|
# 旧格式兼容:L2 无 card subtitle 时从 L3 children 聚合
|
||||||
|
if not l2_card.subtitle:
|
||||||
|
l3_subs = [n.card.subtitle for n in l3_nodes if n.card.subtitle]
|
||||||
|
if l3_subs:
|
||||||
|
l2_card = dataclasses.replace(l2_card, subtitle="\n".join(l3_subs))
|
||||||
tr2 = l2d.get("time_range")
|
tr2 = l2d.get("time_range")
|
||||||
l2_nodes.append(
|
l2_nodes.append(
|
||||||
L2Node(
|
L2Node(
|
||||||
|
|||||||
Reference in New Issue
Block a user