Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

keybindings.test.ts

608 lines22.9 KB

1import { KeybindingCommand, KeybindingRule, KeybindingsConfig } from "@t3tools/contracts";
2import * as NodeServices from "@effect/platform-node/NodeServices";
3import { assert, it } from "@effect/vitest";
4import { assertFailure } from "@effect/vitest/utils";
5import * as Cause from "effect/Cause";
6import * as Effect from "effect/Effect";
7import * as FileSystem from "effect/FileSystem";
8import * as Layer from "effect/Layer";
9import * as Logger from "effect/Logger";
10import * as Path from "effect/Path";
11import * as Schema from "effect/Schema";
12import * as ServerConfig from "./config.ts";
13import * as Keybindings from "./keybindings.ts";
14import { KeybindingsConfigError } from "@t3tools/contracts";
15​
16const KeybindingsConfigJson = Schema.fromJsonString(KeybindingsConfig);
17const encodeKeybindingsConfigJson = Schema.encodeEffect(KeybindingsConfigJson);
18const decodeKeybindingsConfigJson = Schema.decodeUnknownEffect(KeybindingsConfigJson);
19const encodeResolvedKeybindingFromConfig = Schema.encodeEffect(
20 Keybindings.ResolvedKeybindingFromConfig,
21);
22const decodeResolvedKeybindingFromConfigExit = Schema.decodeUnknownExit(
23 Keybindings.ResolvedKeybindingFromConfig,
24);
25const makeKeybindingsLayer = () => {
26 return Keybindings.layer.pipe(
27 Layer.provideMerge(
28 Layer.fresh(
29 ServerConfig.layerTest(process.cwd(), {
30 prefix: "t3code-keybindings-test-",
31 }),
32 ),
33 ),
34 );
35};
36​
37const toDetailResult = <A, R>(effect: Effect.Effect<A, KeybindingsConfigError, R>) =>
38 effect.pipe(
39 Effect.mapError((error) => error.detail),
40 Effect.result,
41 );
42​
43const writeKeybindingsConfig = (configPath: string, rules: readonly KeybindingRule[]) =>
44 Effect.gen(function* () {
45 const fileSystem = yield* FileSystem.FileSystem;
46 const path = yield* Path.Path;
47 const encoded = yield* encodeKeybindingsConfigJson(rules);
48 yield* fileSystem.makeDirectory(path.dirname(configPath), { recursive: true });
49 yield* fileSystem.writeFileString(configPath, encoded);
50 });
51​
52const readKeybindingsConfig = (configPath: string) =>
53 Effect.gen(function* () {
54 const fileSystem = yield* FileSystem.FileSystem;
55 const rawConfig = yield* fileSystem.readFileString(configPath);
56 return yield* decodeKeybindingsConfigJson(rawConfig);
57 });
58​
59it.layer(NodeServices.layer)("keybindings", (it) => {
60 it.effect("parses shortcuts including plus key", () =>
61 Effect.sync(() => {
62 assert.deepEqual(Keybindings.parseKeybindingShortcut("mod+j"), {
63 key: "j",
64 metaKey: false,
65 ctrlKey: false,
66 shiftKey: false,
67 altKey: false,
68 modKey: true,
69 });
70 assert.deepEqual(Keybindings.parseKeybindingShortcut("mod++"), {
71 key: "+",
72 metaKey: false,
73 ctrlKey: false,
74 shiftKey: false,
75 altKey: false,
76 modKey: true,
77 });
78 }),
79 );
80​
81 it.effect("compiles valid rule with parsed when AST", () =>
82 Effect.sync(() => {
83 const compiled = Keybindings.compileResolvedKeybindingRule({
84 key: "mod+d",
85 command: "terminal.split",
86 when: "terminalOpen && !terminalFocus",
87 });
88​
89 assert.deepEqual(compiled, {
90 command: "terminal.split",
91 shortcut: {
92 key: "d",
93 metaKey: false,
94 ctrlKey: false,
95 shiftKey: false,
96 altKey: false,
97 modKey: true,
98 },
99 whenAst: {
100 type: "and",
101 left: { type: "identifier", name: "terminalOpen" },
102 right: {
103 type: "not",
104 node: { type: "identifier", name: "terminalFocus" },
105 },
106 },
107 });
108 }),
109 );
110​
111 it.effect("encodes resolved plus-key shortcuts", () =>
112 Effect.gen(function* () {
113 const encoded = yield* encodeResolvedKeybindingFromConfig({
114 command: "terminal.toggle",
115 shortcut: {
116 key: "+",
117 metaKey: false,
118 ctrlKey: false,
119 shiftKey: false,
120 altKey: false,
121 modKey: true,
122 },
123 });
124​
125 assert.equal(encoded.key, "mod++");
126 assert.equal(encoded.command, "terminal.toggle");
127 }),
128 );
129​
130 it.effect("rejects invalid rules", () =>
131 Effect.sync(() => {
132 assert.isNull(
133 Keybindings.compileResolvedKeybindingRule({
134 key: "mod+shift+d+o",
135 command: "terminal.new",
136 }),
137 );
138​
139 assert.isNull(
140 Keybindings.compileResolvedKeybindingRule({
141 key: "mod+d",
142 command: "terminal.split",
143 when: "terminalFocus && (",
144 }),
145 );
146​
147 assert.isNull(
148 Keybindings.compileResolvedKeybindingRule({
149 key: "mod+d",
150 command: "terminal.split",
151 when: `${"!".repeat(300)}terminalFocus`,
152 }),
153 );
154 }),
155 );
156​
157 it.effect("formats invalid resolved keybinding rules with the custom message", () =>
158 Effect.sync(() => {
159 const result = decodeResolvedKeybindingFromConfigExit({
160 key: "mod+shift+d+o",
161 command: "terminal.new",
162 });
163​
164 if (result._tag !== "Failure") {
165 assert.fail("Expected invalid keybinding decode to fail");
166 }
167​
168 const detail = Cause.pretty(result.cause);
169 assert.isTrue(detail.includes("Invalid keybinding rule"));
170 assert.isFalse(detail.includes("Invalid data"));
171 }),
172 );
173​
174 it.effect("bootstraps default keybindings when config file is missing", () =>
175 Effect.gen(function* () {
176 const fs = yield* FileSystem.FileSystem;
177 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
178 assert.isFalse(yield* fs.exists(keybindingsConfigPath));
179​
180 yield* Effect.gen(function* () {
181 const keybindings = yield* Keybindings.Keybindings;
182 yield* keybindings.syncDefaultKeybindingsOnStartup;
183 });
184​
185 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
186 assert.deepEqual(persisted, Keybindings.DEFAULT_KEYBINDINGS);
187 }).pipe(Effect.provide(makeKeybindingsLayer())),
188 );
189​
190 it.effect("ships configurable thread navigation defaults", () =>
191 Effect.sync(() => {
192 const defaultsByCommand = new Map(
193 Keybindings.DEFAULT_KEYBINDINGS.map((binding) => [binding.command, binding.key] as const),
194 );
195​
196 assert.equal(defaultsByCommand.get("thread.previous"), "mod+shift+[");
197 assert.equal(defaultsByCommand.get("thread.next"), "mod+shift+]");
198 assert.equal(defaultsByCommand.get("thread.settle"), "mod+shift+s");
199 assert.equal(defaultsByCommand.get("thread.jump.1"), "mod+1");
200 assert.equal(defaultsByCommand.get("thread.jump.9"), "mod+9");
201 assert.equal(defaultsByCommand.get("modelPicker.toggle"), "mod+shift+m");
202 assert.equal(defaultsByCommand.get("themeEditor.toggle"), "mod+alt+shift+t");
203 assert.equal(defaultsByCommand.get("filePicker.toggle"), "mod+p");
204 assert.equal(defaultsByCommand.get("projectSearch.toggle"), "mod+shift+f");
205 assert.equal(defaultsByCommand.get("sidebar.toggle"), "mod+b");
206 assert.equal(defaultsByCommand.get("rightPanel.toggle"), "mod+alt+b");
207 assert.isFalse(defaultsByCommand.has("rightPanel.toggleMaximized"));
208 assert.equal(defaultsByCommand.get("terminal.splitVertical"), "mod+shift+d");
209 assert.equal(defaultsByCommand.get("modelPicker.jump.1"), "mod+1");
210 assert.equal(defaultsByCommand.get("modelPicker.jump.9"), "mod+9");
211 }),
212 );
213​
214 it.effect("uses defaults in runtime when config is malformed without overriding file", () =>
215 Effect.gen(function* () {
216 const fs = yield* FileSystem.FileSystem;
217 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
218 yield* fs.writeFileString(keybindingsConfigPath, "{ not-json");
219​
220 const configState = yield* Effect.gen(function* () {
221 const keybindings = yield* Keybindings.Keybindings;
222 return yield* keybindings.loadConfigState;
223 });
224​
225 assert.deepEqual(
226 configState.keybindings,
227 Keybindings.compileResolvedKeybindingsConfig(Keybindings.DEFAULT_KEYBINDINGS),
228 );
229 assert.deepEqual(configState.issues, [
230 {
231 kind: "keybindings.malformed-config",
232 message: configState.issues[0]?.message ?? "",
233 },
234 ]);
235 assert.equal(yield* fs.readFileString(keybindingsConfigPath), "{ not-json");
236 }).pipe(Effect.provide(makeKeybindingsLayer())),
237 );
238​
239 it.effect("ignores invalid entries in runtime and reports them as issues", () =>
240 Effect.gen(function* () {
241 const fs = yield* FileSystem.FileSystem;
242 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
243 yield* fs.writeFileString(
244 keybindingsConfigPath,
245 // @effect-diagnostics-next-line preferSchemaOverJson:off
246 JSON.stringify([
247 { key: "mod+j", command: "terminal.toggle" },
248 { key: "mod+shift+d+o", command: "terminal.new" },
249 { key: "mod+x", command: "invalid.command" },
250 ]),
251 );
252​
253 const configState = yield* Effect.gen(function* () {
254 const keybindings = yield* Keybindings.Keybindings;
255 return yield* keybindings.loadConfigState;
256 });
257​
258 assert.isTrue(configState.keybindings.some((entry) => entry.command === "terminal.toggle"));
259 assert.isFalse(
260 configState.keybindings.some((entry) => String(entry.command) === "invalid.command"),
261 );
262 assert.deepEqual(configState.issues, [
263 {
264 kind: "keybindings.invalid-entry",
265 index: 1,
266 message: configState.issues[0]?.message ?? "",
267 },
268 {
269 kind: "keybindings.invalid-entry",
270 index: 2,
271 message: configState.issues[1]?.message ?? "",
272 },
273 ]);
274 }).pipe(Effect.provide(makeKeybindingsLayer())),
275 );
276​
277 it.effect(
278 "upserts missing default keybindings on startup without overriding existing command rules",
279 () =>
280 Effect.gen(function* () {
281 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
282 yield* writeKeybindingsConfig(keybindingsConfigPath, [
283 { key: "mod+shift+t", command: "terminal.toggle" },
284 { key: "mod+shift+r", command: "script.run-tests.run" },
285 ]);
286​
287 yield* Effect.gen(function* () {
288 const keybindings = yield* Keybindings.Keybindings;
289 yield* keybindings.syncDefaultKeybindingsOnStartup;
290 });
291​
292 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
293 const byCommand = new Map(persisted.map((entry) => [entry.command, entry]));
294​
295 const persistedToggle = byCommand.get("terminal.toggle");
296 assert.isNotNull(persistedToggle);
297 assert.equal(persistedToggle?.key, "mod+shift+t");
298 assert.isFalse(
299 persisted.some((entry) => entry.command === "terminal.toggle" && entry.key === "mod+j"),
300 );
301​
302 for (const defaultRule of Keybindings.DEFAULT_KEYBINDINGS) {
303 assert.isTrue(byCommand.has(defaultRule.command), `expected ${defaultRule.command}`);
304 }
305 assert.isTrue(byCommand.has("script.run-tests.run"));
306 }).pipe(Effect.provide(makeKeybindingsLayer())),
307 );
308​
309 it.effect("skips conflicting default keybindings on startup and logs a detailed warning", () => {
310 const messages: string[] = [];
311 const logger = Logger.make(({ message }) => {
312 messages.push(String(message));
313 });
314​
315 return Effect.gen(function* () {
316 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
317 yield* writeKeybindingsConfig(keybindingsConfigPath, [
318 { key: "mod+j", command: "script.custom-action.run" },
319 ]);
320​
321 yield* Effect.gen(function* () {
322 const keybindings = yield* Keybindings.Keybindings;
323 yield* keybindings.syncDefaultKeybindingsOnStartup;
324 });
325​
326 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
327 assert.isFalse(persisted.some((entry) => entry.command === "terminal.toggle"));
328 assert.isTrue(persisted.some((entry) => entry.command === "script.custom-action.run"));
329​
330 assert.isTrue(
331 messages.some((message) =>
332 message.includes("skipping default keybinding due to shortcut conflict"),
333 ),
334 );
335 }).pipe(
336 Effect.provide(
337 Layer.mergeAll(
338 makeKeybindingsLayer(),
339 Logger.layer([logger], { mergeWithExisting: false }),
340 ),
341 ),
342 );
343 });
344​
345 it.effect("upserts custom keybindings to configured path", () =>
346 Effect.gen(function* () {
347 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
348 yield* writeKeybindingsConfig(keybindingsConfigPath, [
349 { key: "mod+j", command: "terminal.toggle" },
350 ]);
351​
352 const resolved = yield* Effect.gen(function* () {
353 const keybindings = yield* Keybindings.Keybindings;
354 return yield* keybindings.upsertKeybindingRule({
355 key: "mod+shift+r",
356 command: "script.run-tests.run",
357 });
358 });
359​
360 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
361 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
362​
363 assert.deepEqual(persistedView, [
364 { key: "mod+j", command: "terminal.toggle" },
365 { key: "mod+shift+r", command: "script.run-tests.run" },
366 ]);
367 assert.isTrue(resolved.some((entry) => entry.command === "script.run-tests.run"));
368 }).pipe(Effect.provide(makeKeybindingsLayer())),
369 );
370​
371 it.effect("appends additional custom keybindings for the same command", () =>
372 Effect.gen(function* () {
373 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
374 yield* writeKeybindingsConfig(keybindingsConfigPath, [
375 { key: "mod+r", command: "script.run-tests.run" },
376 ]);
377 yield* Effect.gen(function* () {
378 const keybindings = yield* Keybindings.Keybindings;
379 return yield* keybindings.upsertKeybindingRule({
380 key: "mod+shift+r",
381 command: "script.run-tests.run",
382 });
383 });
384​
385 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
386 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
387 assert.deepEqual(persistedView, [
388 { key: "mod+r", command: "script.run-tests.run" },
389 { key: "mod+shift+r", command: "script.run-tests.run" },
390 ]);
391 }).pipe(Effect.provide(makeKeybindingsLayer())),
392 );
393​
394 it.effect("replaces only the targeted custom keybinding", () =>
395 Effect.gen(function* () {
396 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
397 yield* writeKeybindingsConfig(keybindingsConfigPath, [
398 { key: "mod+r", command: "script.run-tests.run" },
399 { key: "mod+shift+r", command: "script.run-tests.run" },
400 ]);
401 yield* Effect.gen(function* () {
402 const keybindings = yield* Keybindings.Keybindings;
403 return yield* keybindings.upsertKeybindingRule({
404 key: "mod+alt+r",
405 command: "script.run-tests.run",
406 replace: { key: "mod+r", command: "script.run-tests.run" },
407 });
408 });
409​
410 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
411 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
412 assert.deepEqual(persistedView, [
413 { key: "mod+shift+r", command: "script.run-tests.run" },
414 { key: "mod+alt+r", command: "script.run-tests.run" },
415 ]);
416 }).pipe(Effect.provide(makeKeybindingsLayer())),
417 );
418​
419 it.effect("replacing with a rule that already exists elsewhere does not duplicate it", () =>
420 Effect.gen(function* () {
421 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
422 yield* writeKeybindingsConfig(keybindingsConfigPath, [
423 { key: "mod+r", command: "script.run-tests.run" },
424 { key: "mod+alt+r", command: "script.run-tests.run" },
425 ]);
426 yield* Effect.gen(function* () {
427 const keybindings = yield* Keybindings.Keybindings;
428 return yield* keybindings.upsertKeybindingRule({
429 key: "mod+alt+r",
430 command: "script.run-tests.run",
431 replace: { key: "mod+r", command: "script.run-tests.run" },
432 });
433 });
434​
435 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
436 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
437 assert.deepEqual(persistedView, [{ key: "mod+alt+r", command: "script.run-tests.run" }]);
438 }).pipe(Effect.provide(makeKeybindingsLayer())),
439 );
440​
441 it.effect("removes only the targeted custom keybinding", () =>
442 Effect.gen(function* () {
443 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
444 yield* writeKeybindingsConfig(keybindingsConfigPath, [
445 { key: "mod+r", command: "script.run-tests.run" },
446 { key: "mod+shift+r", command: "script.run-tests.run" },
447 ]);
448 yield* Effect.gen(function* () {
449 const keybindings = yield* Keybindings.Keybindings;
450 return yield* keybindings.removeKeybindingRule({
451 key: "mod+r",
452 command: "script.run-tests.run",
453 });
454 });
455​
456 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
457 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
458 assert.deepEqual(persistedView, [{ key: "mod+shift+r", command: "script.run-tests.run" }]);
459 }).pipe(Effect.provide(makeKeybindingsLayer())),
460 );
461​
462 it.effect("refuses to overwrite malformed keybindings config", () =>
463 Effect.gen(function* () {
464 const fs = yield* FileSystem.FileSystem;
465 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
466 yield* fs.writeFileString(keybindingsConfigPath, "{ not-json");
467​
468 const result = yield* Effect.gen(function* () {
469 const keybindings = yield* Keybindings.Keybindings;
470 return yield* keybindings.upsertKeybindingRule({
471 key: "mod+shift+r",
472 command: "script.run-tests.run",
473 });
474 }).pipe(toDetailResult);
475 assertFailure(result, "expected JSON array");
476​
477 const persistedRaw = yield* fs.readFileString(keybindingsConfigPath);
478 assert.equal(persistedRaw, "{ not-json");
479 }).pipe(Effect.provide(makeKeybindingsLayer())),
480 );
481​
482 it.effect("reports non-array config parse errors without duplicate prefix", () =>
483 Effect.gen(function* () {
484 const fs = yield* FileSystem.FileSystem;
485 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
486 yield* fs.writeFileString(
487 keybindingsConfigPath,
488 '{"key":"mod+j","command":"terminal.toggle"}',
489 );
490​
491 const firstResult = yield* Effect.gen(function* () {
492 const keybindings = yield* Keybindings.Keybindings;
493 return yield* keybindings.upsertKeybindingRule({
494 key: "mod+shift+r",
495 command: "script.run-tests.run",
496 });
497 }).pipe(toDetailResult);
498 assertFailure(firstResult, "expected JSON array");
499​
500 const secondResult = yield* Effect.gen(function* () {
501 const keybindings = yield* Keybindings.Keybindings;
502 return yield* keybindings.upsertKeybindingRule({
503 key: "mod+shift+r",
504 command: "script.run-tests.run",
505 });
506 }).pipe(toDetailResult);
507 assertFailure(secondResult, "expected JSON array");
508 }).pipe(Effect.provide(makeKeybindingsLayer())),
509 );
510​
511 it.effect("fails when config directory is not writable", () =>
512 Effect.gen(function* () {
513 const fs = yield* FileSystem.FileSystem;
514 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
515 const { dirname } = yield* Path.Path;
516 yield* writeKeybindingsConfig(keybindingsConfigPath, [
517 { key: "mod+j", command: "terminal.toggle" },
518 ]);
519 yield* fs.chmod(dirname(keybindingsConfigPath), 0o500);
520​
521 const result = yield* Effect.gen(function* () {
522 const keybindings = yield* Keybindings.Keybindings;
523 return yield* keybindings.upsertKeybindingRule({
524 key: "mod+shift+r",
525 command: "script.run-tests.run",
526 });
527 }).pipe(toDetailResult);
528 assertFailure(result, "failed to write keybindings config");
529​
530 yield* fs.chmod(dirname(keybindingsConfigPath), 0o700);
531​
532 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
533 const persistedView = persisted.map(({ key, command }) => ({ key, command }));
534 assert.deepEqual(persistedView, [{ key: "mod+j", command: "terminal.toggle" }]);
535 }).pipe(Effect.provide(makeKeybindingsLayer())),
536 );
537​
538 it.effect("caches loaded resolved config across repeated reads", () =>
539 Effect.gen(function* () {
540 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
541 yield* writeKeybindingsConfig(keybindingsConfigPath, [
542 { key: "mod+j", command: "terminal.toggle" },
543 ]);
544​
545 const [first, second] = yield* Effect.gen(function* () {
546 const keybindings = yield* Keybindings.Keybindings;
547 const firstLoad = (yield* keybindings.loadConfigState).keybindings;
548 const secondLoad = (yield* keybindings.loadConfigState).keybindings;
549 return [firstLoad, secondLoad] as const;
550 });
551​
552 assert.deepEqual(first, second);
553 assert.isTrue(second.some((entry) => entry.command === "terminal.toggle"));
554 }).pipe(Effect.provide(makeKeybindingsLayer())),
555 );
556​
557 it.effect("updates cached resolved config after upsert", () =>
558 Effect.gen(function* () {
559 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
560 yield* writeKeybindingsConfig(keybindingsConfigPath, [
561 { key: "mod+j", command: "terminal.toggle" },
562 ]);
563​
564 const loadedAfterUpsert = yield* Effect.gen(function* () {
565 const keybindings = yield* Keybindings.Keybindings;
566 yield* keybindings.loadConfigState;
567 yield* keybindings.upsertKeybindingRule({
568 key: "mod+shift+r",
569 command: "script.run-tests.run",
570 });
571 return (yield* keybindings.loadConfigState).keybindings;
572 });
573​
574 assert.isTrue(loadedAfterUpsert.some((entry) => entry.command === "script.run-tests.run"));
575 assert.isTrue(loadedAfterUpsert.some((entry) => entry.command === "terminal.toggle"));
576 }).pipe(Effect.provide(makeKeybindingsLayer())),
577 );
578​
579 it.effect("serializes concurrent upserts to avoid lost updates", () =>
580 Effect.gen(function* () {
581 const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
582 yield* writeKeybindingsConfig(keybindingsConfigPath, []);
583​
584 const commands = Array.from(
585 { length: 20 },
586 (_, index): KeybindingCommand => `script.concurrent-${index}.run`,
587 );
588 yield* Effect.gen(function* () {
589 const keybindings = yield* Keybindings.Keybindings;
590 yield* Effect.all(
591 commands.map((command, index) =>
592 keybindings.upsertKeybindingRule({
593 key: `mod+${String.fromCharCode(97 + index)}`,
594 command,
595 }),
596 ),
597 { concurrency: "unbounded", discard: true },
598 );
599 });
600​
601 const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
602 const persistedCommands = new Set(persisted.map((entry) => entry.command));
603 for (const command of commands) {
604 assert.isTrue(persistedCommands.has(command), `expected persisted command ${command}`);
605 }
606 }).pipe(Effect.provide(makeKeybindingsLayer())),
607 );
608});