Skip to content

Commit 72e1ab8

Browse files
committed
fix(ios): keep chat segment IDs out of localization
1 parent e01f23a commit 72e1ab8

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

apps/.i18n/native-source.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21851,79 +21851,79 @@
2185121851
},
2185221852
{
2185321853
"kind": "ui-call",
21854-
"line": 440,
21854+
"line": 438,
2185521855
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2185621856
"source": "Retry Send",
2185721857
"surface": "apple",
2185821858
"id": "native.apple.5824df4efbf6c977"
2185921859
},
2186021860
{
2186121861
"kind": "ui-call",
21862-
"line": 454,
21862+
"line": 452,
2186321863
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2186421864
"source": "Delete",
2186521865
"surface": "apple",
2186621866
"id": "native.apple.cdad35e9657fa693"
2186721867
},
2186821868
{
2186921869
"kind": "ui-call",
21870-
"line": 485,
21870+
"line": 483,
2187121871
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2187221872
"source": "Stop Listening",
2187321873
"surface": "apple",
2187421874
"id": "native.apple.9d58b2a2a23c0d69"
2187521875
},
2187621876
{
2187721877
"kind": "ui-call",
21878-
"line": 488,
21878+
"line": 486,
2187921879
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2188021880
"source": "Listen",
2188121881
"surface": "apple",
2188221882
"id": "native.apple.99df7de891c8235f"
2188321883
},
2188421884
{
2188521885
"kind": "ui-call",
21886-
"line": 535,
21886+
"line": 533,
2188721887
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2188821888
"source": "Copy Message",
2188921889
"surface": "apple",
2189021890
"id": "native.apple.fe9f30f12f1dcfaf"
2189121891
},
2189221892
{
2189321893
"kind": "ui-call",
21894-
"line": 594,
21894+
"line": 592,
2189521895
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2189621896
"source": "Jump to latest",
2189721897
"surface": "apple",
2189821898
"id": "native.apple.f84b674ad395b694"
2189921899
},
2190021900
{
2190121901
"kind": "ui-modifier",
21902-
"line": 605,
21902+
"line": 603,
2190321903
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2190421904
"source": "Jump to latest reply",
2190521905
"surface": "apple",
2190621906
"id": "native.apple.429d825201b2cb85"
2190721907
},
2190821908
{
2190921909
"kind": "ui-named-argument",
21910-
"line": 625,
21910+
"line": 623,
2191121911
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2191221912
"source": "Refresh",
2191321913
"surface": "apple",
2191421914
"id": "native.apple.9ab586b85834705c"
2191521915
},
2191621916
{
2191721917
"kind": "ui-call",
21918-
"line": 1050,
21918+
"line": 1049,
2191921919
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2192021920
"source": "Loading chat",
2192121921
"surface": "apple",
2192221922
"id": "native.apple.28c2691c03030434"
2192321923
},
2192421924
{
2192521925
"kind": "ui-modifier",
21926-
"line": 1130,
21926+
"line": 1129,
2192721927
"path": "apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
2192821928
"source": "Dismiss",
2192921929
"surface": "apple",

apps/shared/OpenClawKit/Sources/OpenClawChatUI/AssistantTextParser.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct AssistantTextSegment: Identifiable {
66
case response
77
}
88

9-
let id: String
9+
let id: Int
1010
let kind: Kind
1111
let text: String
1212
}
@@ -16,7 +16,7 @@ enum AssistantTextParser {
1616
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
1717
guard !trimmed.isEmpty else { return [] }
1818
guard raw.contains("<") else {
19-
return [AssistantTextSegment(id: "response-0", kind: .response, text: trimmed)]
19+
return [AssistantTextSegment(id: 0, kind: .response, text: trimmed)]
2020
}
2121

2222
var segments: [AssistantTextSegment] = []
@@ -51,7 +51,7 @@ enum AssistantTextParser {
5151
}
5252

5353
guard matchedTag else {
54-
return [AssistantTextSegment(id: "response-0", kind: .response, text: trimmed)]
54+
return [AssistantTextSegment(id: 0, kind: .response, text: trimmed)]
5555
}
5656

5757
if includeThinking {
@@ -148,7 +148,6 @@ enum AssistantTextParser {
148148
guard !trimmed.isEmpty else { return }
149149
// Parsing repeats during unrelated view updates. Stable positional IDs keep
150150
// SwiftUI from rebuilding unchanged markdown segments and visibly flickering.
151-
let idPrefix = kind == .thinking ? "thinking" : "response"
152-
segments.append(AssistantTextSegment(id: "\(idPrefix)-\(segments.count)", kind: kind, text: trimmed))
151+
segments.append(AssistantTextSegment(id: segments.count, kind: kind, text: trimmed))
153152
}
154153
}

apps/shared/OpenClawKit/Tests/OpenClawKitTests/AssistantTextParserTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ import Testing
5454
let first = AssistantTextParser.segments(from: raw, includeThinking: true)
5555
let second = AssistantTextParser.segments(from: raw, includeThinking: true)
5656

57-
#expect(first.map(\.id) == ["thinking-0", "response-1"])
57+
#expect(first.map(\.id) == [0, 1])
5858
#expect(first.map(\.id) == second.map(\.id))
5959
}
6060
}

0 commit comments

Comments
 (0)