Skip to content

Commit 4270adc

Browse files
committed
feat(web): split terminal font size by desktop and mobile
1 parent 7743616 commit 4270adc

11 files changed

Lines changed: 765 additions & 194 deletions

File tree

packages/server/src/commands/settings.test.ts

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,16 @@ describe("settings commands", () => {
137137
).toEqual({ value: '"graphite-light"' });
138138
});
139139

140-
it("settings.update persists appearance.terminalFontSize into user_settings", async () => {
140+
it("settings.update persists appearance.desktopTerminalFontSize into user_settings", async () => {
141141
const result = await dispatch(
142142
{
143143
kind: "command",
144-
id: "settings-update-terminal-font-size",
144+
id: "settings-update-desktop-terminal-font-size",
145145
op: "settings.update",
146146
args: {
147147
settings: {
148148
appearance: {
149-
terminalFontSize: 16,
149+
desktopTerminalFontSize: 16,
150150
},
151151
},
152152
},
@@ -156,10 +156,37 @@ describe("settings commands", () => {
156156

157157
expect(result.ok).toBe(true);
158158
expect(
159-
db.prepare("SELECT value FROM user_settings WHERE key = ?").get("appearance.terminalFontSize")
159+
db
160+
.prepare("SELECT value FROM user_settings WHERE key = ?")
161+
.get("appearance.desktopTerminalFontSize")
160162
).toEqual({ value: "16" });
161163
});
162164

165+
it("settings.update persists appearance.mobileTerminalFontSize into user_settings", async () => {
166+
const result = await dispatch(
167+
{
168+
kind: "command",
169+
id: "settings-update-mobile-terminal-font-size",
170+
op: "settings.update",
171+
args: {
172+
settings: {
173+
appearance: {
174+
mobileTerminalFontSize: 15,
175+
},
176+
},
177+
},
178+
},
179+
ctx
180+
);
181+
182+
expect(result.ok).toBe(true);
183+
expect(
184+
db
185+
.prepare("SELECT value FROM user_settings WHERE key = ?")
186+
.get("appearance.mobileTerminalFontSize")
187+
).toEqual({ value: "15" });
188+
});
189+
163190
it("settings.update persists legacy appearance.theme light during themeId migration", async () => {
164191
const result = await dispatch(
165192
{
@@ -261,16 +288,16 @@ describe("settings commands", () => {
261288
).toBeUndefined();
262289
});
263290

264-
it("settings.update rejects terminalFontSize values below the supported minimum", async () => {
291+
it("settings.update rejects desktopTerminalFontSize values below the supported minimum", async () => {
265292
const result = await dispatch(
266293
{
267294
kind: "command",
268-
id: "settings-update-terminal-font-size-too-small",
295+
id: "settings-update-desktop-terminal-font-size-too-small",
269296
op: "settings.update",
270297
args: {
271298
settings: {
272299
appearance: {
273-
terminalFontSize: 9,
300+
desktopTerminalFontSize: 9,
274301
},
275302
},
276303
},
@@ -281,20 +308,22 @@ describe("settings commands", () => {
281308
expect(result.ok).toBe(false);
282309
expect(result.error?.code).toBe("validation_error");
283310
expect(
284-
db.prepare("SELECT value FROM user_settings WHERE key = ?").get("appearance.terminalFontSize")
311+
db
312+
.prepare("SELECT value FROM user_settings WHERE key = ?")
313+
.get("appearance.desktopTerminalFontSize")
285314
).toBeUndefined();
286315
});
287316

288-
it("settings.update rejects terminalFontSize values above the supported maximum", async () => {
317+
it("settings.update rejects mobileTerminalFontSize values above the supported maximum", async () => {
289318
const result = await dispatch(
290319
{
291320
kind: "command",
292-
id: "settings-update-terminal-font-size-too-large",
321+
id: "settings-update-mobile-terminal-font-size-too-large",
293322
op: "settings.update",
294323
args: {
295324
settings: {
296325
appearance: {
297-
terminalFontSize: 19,
326+
mobileTerminalFontSize: 19,
298327
},
299328
},
300329
},
@@ -305,20 +334,22 @@ describe("settings commands", () => {
305334
expect(result.ok).toBe(false);
306335
expect(result.error?.code).toBe("validation_error");
307336
expect(
308-
db.prepare("SELECT value FROM user_settings WHERE key = ?").get("appearance.terminalFontSize")
337+
db
338+
.prepare("SELECT value FROM user_settings WHERE key = ?")
339+
.get("appearance.mobileTerminalFontSize")
309340
).toBeUndefined();
310341
});
311342

312-
it("settings.update rejects fractional terminalFontSize values", async () => {
343+
it("settings.update rejects fractional desktopTerminalFontSize values", async () => {
313344
const result = await dispatch(
314345
{
315346
kind: "command",
316-
id: "settings-update-terminal-font-size-fractional",
347+
id: "settings-update-desktop-terminal-font-size-fractional",
317348
op: "settings.update",
318349
args: {
319350
settings: {
320351
appearance: {
321-
terminalFontSize: 15.5,
352+
desktopTerminalFontSize: 15.5,
322353
},
323354
},
324355
},
@@ -329,7 +360,9 @@ describe("settings commands", () => {
329360
expect(result.ok).toBe(false);
330361
expect(result.error?.code).toBe("validation_error");
331362
expect(
332-
db.prepare("SELECT value FROM user_settings WHERE key = ?").get("appearance.terminalFontSize")
363+
db
364+
.prepare("SELECT value FROM user_settings WHERE key = ?")
365+
.get("appearance.desktopTerminalFontSize")
333366
).toBeUndefined();
334367
});
335368

@@ -551,16 +584,20 @@ describe("settings commands", () => {
551584
});
552585
});
553586

554-
it("settings.get returns appearance.terminalFontSize from user_settings", async () => {
587+
it("settings.get returns split terminal font size settings from user_settings", async () => {
555588
db.prepare("INSERT INTO user_settings (key, value) VALUES (?, ?)").run(
556-
"appearance.terminalFontSize",
589+
"appearance.desktopTerminalFontSize",
557590
"16"
558591
);
592+
db.prepare("INSERT INTO user_settings (key, value) VALUES (?, ?)").run(
593+
"appearance.mobileTerminalFontSize",
594+
"14"
595+
);
559596

560597
const result = await dispatch(
561598
{
562599
kind: "command",
563-
id: "settings-get-terminal-font-size",
600+
id: "settings-get-split-terminal-font-size",
564601
op: "settings.get",
565602
args: {},
566603
},
@@ -569,7 +606,8 @@ describe("settings commands", () => {
569606

570607
expect(result.ok).toBe(true);
571608
expect(result.data).toMatchObject({
572-
"appearance.terminalFontSize": 16,
609+
"appearance.desktopTerminalFontSize": 16,
610+
"appearance.mobileTerminalFontSize": 14,
573611
});
574612
});
575613

packages/server/src/commands/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const SettingsSchema = z.object({
7070
terminalRenderer: z.enum(["standard", "compatibility"]).optional(),
7171
terminalCopyOnSelect: z.boolean().optional(),
7272
terminalFontSize: z.number().int().min(10).max(18).optional(),
73+
desktopTerminalFontSize: z.number().int().min(10).max(18).optional(),
74+
mobileTerminalFontSize: z.number().int().min(10).max(18).optional(),
7375
locale: z.enum(["zh", "en"]).optional(),
7476
})
7577
.optional(),

0 commit comments

Comments
 (0)