Skip to content

Commit b9d025e

Browse files
klopez4212Queueclaude
committed
fix(mobile): seed an accent older clients accept
New installs seed and publish the default without a picker action, and pre-Chartreuse readers reject an unknown v1 accent along with the whole preference. Default to Cobalt (#3b82f6), matching Desktop and main, and assert in both clients' contract tests that automatically published accents stay within the base readers' set. Co-authored-by: Queue <874bf2d815c2c4b459b90438c669c57f2702f3a76bb6e16fa97184259aac3e9e@buzz.block.builderlab.xyz> Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: kenny lopez <[email protected]>
1 parent f30ab55 commit b9d025e

5 files changed

Lines changed: 96 additions & 18 deletions

File tree

‎desktop/src/shared/theme/communityThemePreference.test.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ test("accents follow the cross-client v1 contract", () => {
7878
for (const accent of contract.rejected) {
7979
assert.equal(parseCommunityThemePreference({ ...base, accent }), null);
8080
}
81+
// Older clients reject an unknown accent with the whole preference, so the
82+
// default published without a picker action stays in their set.
83+
assert.ok(
84+
contract.baseReaders.accepted.includes(DEFAULT_COMMUNITY_THEME.accent),
85+
);
8186
});
8287

8388
test("local preferences are isolated by pubkey and normalized relay", () => {

‎mobile/lib/shared/theme/community_theme_preference.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import 'theme_provider.dart' show effectiveTheme, schemeForAppearanceMode;
1111
const communityThemeDTag = 'community-theme';
1212
const defaultCommunityTheme = CommunityThemePreference(
1313
theme: 'buzz',
14-
accent: '#d7d72e', // Chartreuse
14+
// Seeded without a picker action, so it must stay readable by older clients.
15+
accent: '#3b82f6', // Cobalt
1516
followSystem: true,
1617
);
1718

‎mobile/test/shared/theme/chat_colors_test.dart‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,17 @@ void main() {
8484
// Family names from earlier preview builds republish as the v1 value.
8585
expect(parse(chatColorChoices[index].name.toLowerCase()).accent, accent);
8686
}
87-
expect(
88-
emitted.map((entry) => entry['accent']),
89-
contains(defaultCommunityTheme.accent),
90-
);
87+
// Older clients reject an unknown accent with the whole preference, so
88+
// anything published without a picker action stays in their set.
89+
final baseReaders = ((contract['baseReaders'] as Map)['accepted'] as List)
90+
.cast<String>();
91+
for (final automatic in [
92+
defaultCommunityTheme.accent,
93+
for (final index in [null, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8])
94+
legacyAccentWireValue(index),
95+
]) {
96+
expect(baseReaders, contains(automatic));
97+
}
9198

9299
final legacy = (contract['legacy'] as List).cast<Map<String, dynamic>>();
93100
for (final entry in [...emitted, ...legacy]) {

‎mobile/test/shared/theme/community_theme_provider_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void main() {
112112
notifier.setTheme('dracula');
113113
const local = CommunityThemePreference(
114114
theme: 'dracula',
115-
accent: '#d7d72e',
115+
accent: '#3b82f6',
116116
followSystem: true,
117117
);
118118
expect(container.read(communityThemeProvider), local);
Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,83 @@
11
{
22
"emitted": [
3-
{ "family": "Gray", "accent": "neutral", "desktop": "Neutral" },
4-
{ "family": "Chartreuse", "accent": "#d7d72e", "desktop": "Chartreuse" },
5-
{ "family": "Flame", "accent": "#f97316", "desktop": "Orange" },
6-
{ "family": "Magenta", "accent": "#ec4899", "desktop": "Pink" },
7-
{ "family": "Iris", "accent": "#c0a2f1", "desktop": "Lilac" },
8-
{ "family": "Cobalt", "accent": "#3b82f6", "desktop": "Blue" },
9-
{ "family": "Jade", "accent": "#22c55e", "desktop": "Green" }
3+
{
4+
"family": "Gray",
5+
"accent": "neutral",
6+
"desktop": "Neutral"
7+
},
8+
{
9+
"family": "Chartreuse",
10+
"accent": "#d7d72e",
11+
"desktop": "Chartreuse"
12+
},
13+
{
14+
"family": "Flame",
15+
"accent": "#f97316",
16+
"desktop": "Orange"
17+
},
18+
{
19+
"family": "Magenta",
20+
"accent": "#ec4899",
21+
"desktop": "Pink"
22+
},
23+
{
24+
"family": "Iris",
25+
"accent": "#c0a2f1",
26+
"desktop": "Lilac"
27+
},
28+
{
29+
"family": "Cobalt",
30+
"accent": "#3b82f6",
31+
"desktop": "Blue"
32+
},
33+
{
34+
"family": "Jade",
35+
"accent": "#22c55e",
36+
"desktop": "Green"
37+
}
1038
],
1139
"legacy": [
12-
{ "accent": "#06b6d4", "desktop": "Cyan", "family": "Jade" },
13-
{ "accent": "#ef4444", "desktop": "Red", "family": "Magenta" },
14-
{ "accent": "#a855f7", "desktop": "Purple", "family": "Iris" },
15-
{ "accent": "#6366f1", "desktop": "Indigo", "family": "Cobalt" }
40+
{
41+
"accent": "#06b6d4",
42+
"desktop": "Cyan",
43+
"family": "Jade"
44+
},
45+
{
46+
"accent": "#ef4444",
47+
"desktop": "Red",
48+
"family": "Magenta"
49+
},
50+
{
51+
"accent": "#a855f7",
52+
"desktop": "Purple",
53+
"family": "Iris"
54+
},
55+
{
56+
"accent": "#6366f1",
57+
"desktop": "Indigo",
58+
"family": "Cobalt"
59+
}
1660
],
17-
"rejected": ["url(image)", "#123456", "Chartreuse", "cyan", ""]
61+
"rejected": [
62+
"url(image)",
63+
"#123456",
64+
"Chartreuse",
65+
"cyan",
66+
""
67+
],
68+
"baseReaders": {
69+
"note": "v1 accents accepted by Mobile and Desktop before Chartreuse; anything a client publishes without a picker action must stay in this set",
70+
"accepted": [
71+
"neutral",
72+
"#3b82f6",
73+
"#06b6d4",
74+
"#22c55e",
75+
"#f97316",
76+
"#ef4444",
77+
"#ec4899",
78+
"#c0a2f1",
79+
"#a855f7",
80+
"#6366f1"
81+
]
82+
}
1883
}

0 commit comments

Comments
 (0)