chesspal 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/README.md +11 -12
  2. package/dist/cli/cli.js +83 -3
  3. package/dist/cli/command-line.js +26 -9
  4. package/dist/cli/icon.d.ts +25 -0
  5. package/dist/cli/icon.js +80 -0
  6. package/dist/commands/agents.d.ts +19 -2
  7. package/dist/commands/agents.js +39 -13
  8. package/dist/commands/ai-say.js +3 -4
  9. package/dist/commands/analyse-game.d.ts +4 -0
  10. package/dist/commands/analyse-game.js +46 -13
  11. package/dist/commands/annotate-game.d.ts +2 -0
  12. package/dist/commands/annotate-game.js +40 -18
  13. package/dist/commands/answer-lines.d.ts +2 -0
  14. package/dist/commands/answer-lines.js +13 -3
  15. package/dist/commands/coach.js +4 -2
  16. package/dist/commands/context.d.ts +9 -1
  17. package/dist/commands/context.js +5 -0
  18. package/dist/commands/delete-review.js +9 -5
  19. package/dist/commands/game-summary.d.ts +2 -0
  20. package/dist/commands/game-summary.js +4 -0
  21. package/dist/commands/index.d.ts +3 -2
  22. package/dist/commands/index.js +7 -4
  23. package/dist/commands/init.js +2 -4
  24. package/dist/commands/instructions.d.ts +9 -0
  25. package/dist/commands/instructions.js +30 -0
  26. package/dist/commands/lead-input.d.ts +1 -1
  27. package/dist/commands/lead-input.js +7 -4
  28. package/dist/commands/page-link.js +6 -5
  29. package/dist/commands/past-games.d.ts +1 -1
  30. package/dist/commands/past-games.js +12 -5
  31. package/dist/commands/player-move.js +2 -3
  32. package/dist/commands/profiles.d.ts +23 -9
  33. package/dist/commands/profiles.js +76 -35
  34. package/dist/commands/ratings.d.ts +8 -0
  35. package/dist/commands/ratings.js +45 -0
  36. package/dist/commands/registry.d.ts +1 -1
  37. package/dist/commands/registry.js +3 -2
  38. package/dist/commands/say.d.ts +1 -1
  39. package/dist/commands/say.js +1 -1
  40. package/dist/commands/status.d.ts +3 -1
  41. package/dist/commands/status.js +46 -27
  42. package/dist/commands/study.js +8 -5
  43. package/dist/core/index.d.ts +1 -1
  44. package/dist/core/index.js +1 -1
  45. package/dist/core/review.d.ts +2 -0
  46. package/dist/core/review.js +5 -1
  47. package/dist/games/ai-model.d.ts +4 -2
  48. package/dist/games/ai-model.js +10 -1
  49. package/dist/games/analysis.d.ts +26 -3
  50. package/dist/games/analysis.js +41 -6
  51. package/dist/games/archive.d.ts +6 -3
  52. package/dist/games/archive.js +13 -5
  53. package/dist/games/current-game.d.ts +10 -1
  54. package/dist/games/current-game.js +49 -15
  55. package/dist/games/files.d.ts +5 -0
  56. package/dist/games/files.js +42 -1
  57. package/dist/games/index.d.ts +3 -3
  58. package/dist/games/index.js +3 -3
  59. package/dist/home/data-folder.d.ts +2 -0
  60. package/dist/home/data-folder.js +5 -1
  61. package/dist/home/index.d.ts +1 -1
  62. package/dist/home/index.js +1 -1
  63. package/dist/host-files/agents.d.ts +2 -2
  64. package/dist/host-files/agents.js +12 -6
  65. package/dist/host-files/host-files.d.ts +5 -3
  66. package/dist/host-files/host-files.js +15 -8
  67. package/dist/host-files/index.d.ts +2 -2
  68. package/dist/host-files/index.js +2 -2
  69. package/dist/page/app/app.js +29 -16
  70. package/dist/page/app/title.js +17 -0
  71. package/dist/page/avatars/torretta.js +4 -4
  72. package/dist/page/dialogs/analyses.js +4 -4
  73. package/dist/page/dialogs/dialog.js +4 -1
  74. package/dist/page/dialogs/dialogs.css +84 -10
  75. package/dist/page/dialogs/profiles.js +95 -42
  76. package/dist/page/game/column.js +5 -1
  77. package/dist/page/game/plies.js +7 -4
  78. package/dist/page/guide/blocks.js +67 -0
  79. package/dist/page/guide/en.md +66 -0
  80. package/dist/page/guide/foot.js +18 -0
  81. package/dist/page/guide/guide.css +200 -0
  82. package/dist/page/guide/guide.js +89 -0
  83. package/dist/page/guide/it.md +66 -0
  84. package/dist/page/guide/markdown.js +67 -0
  85. package/dist/page/helps/helps.css +7 -10
  86. package/dist/page/layout/favicon.svg +13 -0
  87. package/dist/page/layout/header.js +3 -3
  88. package/dist/page/layout/icon.icns +0 -0
  89. package/dist/page/layout/icon.ico +0 -0
  90. package/dist/page/layout/icon.png +0 -0
  91. package/dist/page/layout/layout.css +111 -4
  92. package/dist/page/layout/window.js +45 -0
  93. package/dist/page/main.js +4 -1
  94. package/dist/page/players/card.js +1 -1
  95. package/dist/page/profile/profile.js +14 -9
  96. package/dist/page/profile/settings.js +9 -0
  97. package/dist/page/style.css +2 -0
  98. package/dist/page/table/opener.css +65 -0
  99. package/dist/page/table/opener.js +59 -0
  100. package/dist/page/talk/chat.css +10 -3
  101. package/dist/page/talk/talk.css +38 -26
  102. package/dist/page/talk/talk.js +4 -2
  103. package/dist/page/text.js +83 -17
  104. package/dist/page/theme.css +7 -0
  105. package/dist/profiles/index.d.ts +2 -1
  106. package/dist/profiles/index.js +2 -1
  107. package/dist/profiles/profiles.d.ts +10 -15
  108. package/dist/profiles/profiles.js +30 -15
  109. package/dist/profiles/ratings.d.ts +35 -0
  110. package/dist/profiles/ratings.js +61 -0
  111. package/dist/server/bell.d.ts +24 -3
  112. package/dist/server/bell.js +84 -10
  113. package/dist/server/caller.d.ts +2 -1
  114. package/dist/server/caller.js +3 -2
  115. package/dist/server/mcp.d.ts +7 -3
  116. package/dist/server/mcp.js +100 -52
  117. package/dist/server/page/analyses.d.ts +2 -0
  118. package/dist/server/page/analyses.js +20 -5
  119. package/dist/server/page/attach.d.ts +4 -0
  120. package/dist/server/page/attach.js +112 -0
  121. package/dist/server/page/chat.d.ts +60 -0
  122. package/dist/server/page/chat.js +79 -0
  123. package/dist/server/page/events.d.ts +7 -0
  124. package/dist/server/page/events.js +20 -0
  125. package/dist/server/page/files.js +10 -1
  126. package/dist/server/page/game.js +43 -23
  127. package/dist/server/page/page.d.ts +47 -7
  128. package/dist/server/page/page.js +69 -48
  129. package/dist/server/page/profiles.d.ts +5 -0
  130. package/dist/server/page/profiles.js +26 -10
  131. package/dist/server/page/table.d.ts +39 -0
  132. package/dist/server/page/table.js +102 -0
  133. package/dist/server/table/browser.d.ts +6 -0
  134. package/dist/server/table/browser.js +48 -0
  135. package/dist/server/table/hosts/chats.d.ts +7 -0
  136. package/dist/server/table/hosts/chats.js +31 -0
  137. package/dist/server/table/hosts/find.d.ts +2 -0
  138. package/dist/server/table/hosts/find.js +20 -0
  139. package/dist/server/table/hosts/hosts.d.ts +34 -0
  140. package/dist/server/table/hosts/hosts.js +49 -0
  141. package/dist/server/table/hosts/index.d.ts +3 -0
  142. package/dist/server/table/hosts/index.js +4 -0
  143. package/dist/server/table/hosts/play.d.ts +25 -0
  144. package/dist/server/table/hosts/play.js +152 -0
  145. package/dist/server/table/hosts/seat.d.ts +25 -0
  146. package/dist/server/table/hosts/seat.js +74 -0
  147. package/dist/server/table/hosts/terminal.d.ts +6 -0
  148. package/dist/server/table/hosts/terminal.js +63 -0
  149. package/dist/server/table/icon/index.d.ts +32 -0
  150. package/dist/server/table/icon/index.js +83 -0
  151. package/dist/server/table/icon/linux.d.ts +5 -0
  152. package/dist/server/table/icon/linux.js +47 -0
  153. package/dist/server/table/icon/macos.d.ts +3 -0
  154. package/dist/server/table/icon/macos.js +38 -0
  155. package/dist/server/table/icon/windows.d.ts +3 -0
  156. package/dist/server/table/icon/windows.js +48 -0
  157. package/dist/server/table/index.d.ts +6 -0
  158. package/dist/server/table/index.js +7 -0
  159. package/dist/server/table/launch.d.ts +19 -0
  160. package/dist/server/table/launch.js +78 -0
  161. package/dist/server/table/link.d.ts +10 -0
  162. package/dist/server/table/link.js +230 -0
  163. package/dist/server/table/table.d.ts +35 -0
  164. package/dist/server/table/table.js +94 -0
  165. package/dist/sites/chesscom.d.ts +4 -0
  166. package/dist/sites/chesscom.js +25 -0
  167. package/dist/sites/choice.d.ts +17 -0
  168. package/dist/sites/choice.js +13 -0
  169. package/dist/sites/index.d.ts +2 -0
  170. package/dist/sites/index.js +4 -0
  171. package/dist/sites/lichess.d.ts +4 -0
  172. package/dist/sites/lichess.js +32 -0
  173. package/dist/sites/request.d.ts +11 -0
  174. package/dist/sites/request.js +15 -0
  175. package/dist/sites/sites.d.ts +6 -0
  176. package/dist/sites/sites.js +33 -0
  177. package/instructions/analysis.md +1 -1
  178. package/instructions/analyst-agent.md +1 -1
  179. package/instructions/coach.md +2 -1
  180. package/instructions/opponent.md +6 -6
  181. package/instructions/ponder.md +1 -0
  182. package/instructions/start.md +1 -0
  183. package/package.json +1 -1
@@ -553,6 +553,83 @@
553
553
  flex: none;
554
554
  }
555
555
 
556
+ /* Beside the board the talk is a row a side, each half the column, or what its card, note and box need when that is more: only the words give way, and
557
+ never spill over the other side (Stefano, Zoe). Turned round, the player's row comes first. In analysis the AI's note keeps its height while the thread
558
+ gives way, and scrolls by itself only when nothing else is left to give */
559
+ @media (min-width: 841px) {
560
+ .talk {
561
+ display: grid;
562
+ grid-template-rows: minmax(min-content, 1fr) minmax(min-content, 1fr);
563
+ container: talk / size;
564
+ }
565
+
566
+ .ai-block,
567
+ .you-block {
568
+ max-height: none;
569
+ }
570
+
571
+ /* The player's card stays by the board's edge when the words above it go */
572
+ .you-block {
573
+ justify-content: flex-end;
574
+ }
575
+
576
+ .flipped .ai-block {
577
+ grid-row: 2;
578
+ }
579
+
580
+ .flipped .you-block {
581
+ grid-row: 1;
582
+ }
583
+
584
+ /* The words take the room left, and ask none of their own */
585
+ .says,
586
+ .sent {
587
+ flex: 1 1 0;
588
+ contain: size;
589
+ }
590
+
591
+ .talk.studied {
592
+ grid-template-rows: minmax(0, max-content) minmax(min-content, 1fr);
593
+ overflow: hidden;
594
+ }
595
+
596
+ .flipped .talk.studied {
597
+ grid-template-rows: minmax(min-content, 1fr) minmax(0, max-content);
598
+ }
599
+
600
+ .talk.studied > .ai-block > .ai-note {
601
+ flex: 0 1 auto;
602
+ min-height: 0;
603
+ overflow-y: auto;
604
+ }
605
+
606
+ /* On a short column the table's note keeps its buttons and drops the commands to type, then the box and the words go: they wait for a chat anyway.
607
+ In analysis the cards are taller and the AI's note needs room too */
608
+ @container talk (max-height: 560px) {
609
+ .opener-command {
610
+ display: none;
611
+ }
612
+ }
613
+
614
+ @container talk (max-height: 500px) {
615
+ .ai-block:has(> .opener) + .you-block > :is(.sent, .compose) {
616
+ display: none;
617
+ }
618
+ }
619
+
620
+ @container talk (max-height: 640px) {
621
+ .talk.studied .opener-command {
622
+ display: none;
623
+ }
624
+ }
625
+
626
+ @container talk (max-height: 580px) {
627
+ .talk.studied > .ai-block:has(> .opener) + .you-block > .chat {
628
+ display: none;
629
+ }
630
+ }
631
+ }
632
+
556
633
  /* The game's column, which folds from its tab */
557
634
  .side {
558
635
  grid-area: side;
@@ -580,15 +657,22 @@
580
657
  align-items: center;
581
658
  }
582
659
 
583
- /* Between games the chip is never cut: beside it the Torretta stands for the name at every width, and the flip keeps only its icon */
660
+ /* Between games and in analysis the Torretta alone stands for the name, at every width, to leave the chip its room */
584
661
  @media (min-width: 841px) {
585
- .top:has(.verdict.idle, .verdict.over) .title {
662
+ .top:has(.verdict.idle, .verdict.over, .verdict.analysis) .title {
586
663
  display: none;
587
664
  }
588
665
 
589
- .top:has(.verdict.idle, .verdict.over) .verdict {
666
+ .top:has(.verdict.idle, .verdict.over, .verdict.analysis) .verdict {
590
667
  margin-right: auto;
591
668
  }
669
+
670
+ /* Over a board of 760 px or less the sound and the theme leave their room to the chip, and stay in the settings; in a game they come back */
671
+ @container (max-width: 760px) {
672
+ .top:has(.verdict.idle, .verdict.over, .verdict.analysis) :is(.sound-button, .theme-button) {
673
+ display: none;
674
+ }
675
+ }
592
676
  }
593
677
 
594
678
  /* Beside the board, a column's content keeps its width and its outer edge while the column folds: it slides under the board, the text never flows again */
@@ -800,6 +884,23 @@
800
884
  grid-template-areas: "head" "you" "board" "steps" "asleep" "note" "chat" "ai" "side";
801
885
  }
802
886
 
887
+ /* With the helps on, their map under the steps: an area the grid lacks would put it in a column of its own, off the screen */
888
+ .app:has(.talk.studied):has(.board-map) {
889
+ grid-template-areas: "head" "ai" "board" "steps" "map" "note" "chat" "you" "side";
890
+ }
891
+
892
+ .app.flipped:has(.talk.studied):has(.board-map) {
893
+ grid-template-areas: "head" "you" "board" "steps" "map" "note" "chat" "ai" "side";
894
+ }
895
+
896
+ .app:has(.talk.studied > .ai-block > .asleep):has(.board-map) {
897
+ grid-template-areas: "head" "ai" "board" "steps" "map" "asleep" "note" "chat" "you" "side";
898
+ }
899
+
900
+ .app.flipped:has(.talk.studied > .ai-block > .asleep):has(.board-map) {
901
+ grid-template-areas: "head" "you" "board" "steps" "map" "asleep" "note" "chat" "ai" "side";
902
+ }
903
+
803
904
  .talk.studied > .ai-block > .asleep {
804
905
  grid-area: asleep;
805
906
  margin: 0;
@@ -834,12 +935,18 @@
834
935
  box-shadow: 0 8px 24px rgb(0 0 0 / 16%);
835
936
  }
836
937
 
837
- /* On a phone the header's first line holds the Torretta, which stands for the name, and every button down to the player's picture, a little closer */
938
+ /* On a phone the header's first line holds the Torretta, which stands for the name, and every button down to the player's picture, a little closer; the
939
+ sound and the theme stay in the settings */
838
940
  @media (max-width: 420px) {
839
941
  .top {
840
942
  column-gap: 4px;
841
943
  }
842
944
 
945
+ .top .sound-button,
946
+ .top .theme-button {
947
+ display: none;
948
+ }
949
+
843
950
  .top .title {
844
951
  display: none;
845
952
  }
@@ -0,0 +1,45 @@
1
+ // The table's window the first time it opens (D-104): Chrome and Edge open an application window about 1000 px wide, where the page has two columns. The
2
+ // page asks once for 16:9, 1600×900 or what the screen has, centred; after that the browser keeps the size the player gives it (Zoe).
3
+ // The mark the table puts on the address of the window it opens (server/table/browser.ts).
4
+ const mark = "opened";
5
+ const sizedKey = "chesspal-window-sized";
6
+ const wanted = { width: 1600, height: 900 };
7
+ /** Sizes the window the table opened, once in this browser, and takes the mark off the address. */
8
+ export function fitOpenedWindow() {
9
+ const address = new URL(location.href);
10
+ if (!address.searchParams.has(mark)) {
11
+ return;
12
+ }
13
+ address.searchParams.delete(mark);
14
+ history.replaceState(history.state, "", address.pathname + address.search + address.hash);
15
+ if (sizedBefore()) {
16
+ return;
17
+ }
18
+ const place = windowPlace(screen.availWidth, screen.availHeight);
19
+ window.resizeTo(place.width, place.height);
20
+ window.moveTo(place.left, place.top);
21
+ noteSized();
22
+ }
23
+ /** Where the window goes on a screen with this much room: 1600×900, or less on a smaller screen, centred. */
24
+ export function windowPlace(roomWidth, roomHeight) {
25
+ const width = Math.min(wanted.width, roomWidth);
26
+ const height = Math.min(wanted.height, roomHeight);
27
+ return { width, height, left: Math.round((roomWidth - width) / 2), top: Math.round((roomHeight - height) / 2) };
28
+ }
29
+ function sizedBefore() {
30
+ try {
31
+ return localStorage.getItem(sizedKey) !== null;
32
+ }
33
+ catch {
34
+ // A browser that keeps nothing for the page: sizing it at every opening is the lesser harm.
35
+ return false;
36
+ }
37
+ }
38
+ function noteSized() {
39
+ try {
40
+ localStorage.setItem(sizedKey, "1");
41
+ }
42
+ catch {
43
+ // Nothing kept: the next opening sizes the window again.
44
+ }
45
+ }
package/dist/page/main.js CHANGED
@@ -1,8 +1,11 @@
1
1
  import { jsx as _jsx } from "preact/jsx-runtime";
2
- // The page's start: the settings this browser remembers, shown before the first frame, then the app drawn into its place.
2
+ // The page's start: the window the table opened sized the first time, the settings this browser remembers, shown before the first frame, then the app
3
+ // drawn into its place.
3
4
  import { render } from "preact";
4
5
  import { App } from "./app/app.js";
6
+ import { fitOpenedWindow } from "./layout/window.js";
5
7
  import { loadSettings, showSettings } from "./profile/settings.js";
8
+ fitOpenedWindow();
6
9
  const settings = loadSettings();
7
10
  showSettings(settings);
8
11
  render(_jsx(App, { start: settings }), document.getElementById("app"));
@@ -8,7 +8,7 @@ export function PlayerCard({ place, picture, name, signed, side, level, taken, a
8
8
  const opponent = side === "white" ? "black" : "white";
9
9
  return (_jsx("section", { class: `card player ${place}`, children: _jsxs("div", { class: "player-line", children: [picture, _jsxs("div", { class: "who", children: [_jsx("div", { class: "name", title: typeof name === "string" ? name : undefined, children: name }), signed === undefined ? null : _jsx("div", { class: "signed", title: signed, children: signed }), side === undefined ? null : (_jsxs("div", { class: "note", children: [text.sides[side], level === undefined ? null : (_jsxs(_Fragment, { children: [" ", "\u00B7 ", _jsx(LevelTip, { level: level })] })), turn
10
10
  ? (_jsxs(_Fragment, { children: [" ", "\u00B7 ", _jsx("b", { class: "turn", children: text.yourTurn })] }))
11
- : null] })), _jsxs("div", { class: "taken", role: "img", "aria-label": text.taken(taken.map((piece) => text.piece(piece, opponent)), ahead), children: [groupsOf(taken).map((group) => (_jsx("span", { class: group[0]?.toUpperCase() === "P" ? "group pawns" : "group", children: group.map((piece, index) => _jsx(Piece, { letter: opponent === "white" ? piece : piece.toLowerCase(), small: true }, index)) }, group[0]))), ahead > 0 ? _jsxs("span", { class: "balance", children: ["+", ahead] }) : null] }), badges] }), clock] }) }));
11
+ : null] }))] }), clock, side === undefined && taken.length === 0 && badges === undefined ? null : (_jsxs("div", { class: "haul", children: [_jsxs("div", { class: "taken", role: "img", "aria-label": text.taken(taken.map((piece) => text.piece(piece, opponent)), ahead), children: [groupsOf(taken).map((group) => (_jsx("span", { class: group[0]?.toUpperCase() === "P" ? "group pawns" : "group", children: group.map((piece, index) => _jsx(Piece, { letter: opponent === "white" ? piece : piece.toLowerCase(), small: true }, index)) }, group[0]))), ahead > 0 ? _jsxs("span", { class: "balance", children: ["+", ahead] }) : null] }), badges] }))] }) }));
12
12
  }
13
13
  /**
14
14
  * A side's time on the game's clock, as the server keeps it: it runs while the side is to move and the game goes on, unless `held` (a move on its way);
@@ -1,12 +1,15 @@
1
1
  // The player's profile on the page (D-23, D-45): as the server sends it, the choices the wizard offers, and the requests that change it.
2
2
  /** How the player says they play, as the server keeps it. */
3
3
  export const levels = ["learning", "casual", "regular", "tournament"];
4
- /** Where a rating comes from. */
5
- export const ratingSites = ["lichess", "chess.com", "fide"];
6
- /** The lowest and highest rating the server takes. */
7
- export const ratingLimits = { lowest: 100, highest: 3500 };
4
+ /** The sites a rating is read from, by the player's names there (D-105). */
5
+ export const ratingSites = ["lichess", "chess.com"];
6
+ /** The speeds whose rating counts, in the order they count (D-106). */
7
+ export const speeds = ["rapid", "classical", "blitz"];
8
8
  /** The longest name the server keeps. */
9
9
  export const nameLimit = 40;
10
+ /** The FIDE ratings the server takes, as whole numbers (D-106). */
11
+ export const fideLowest = 1400;
12
+ export const fideHighest = 3000;
10
13
  /** The drawn avatars, by the ids the server keeps (D-45). */
11
14
  export const avatarIds = ["short-hair", "bun", "glasses", "beanie", "beard", "curls", "moustache", "silver-bob", "cat", "owl"];
12
15
  /** The address of a profile's own image: it changes with the image. */
@@ -14,12 +17,14 @@ export function imageAddress(profile) {
14
17
  return profile.image === undefined ? undefined : `/api/profile/image?profile=${encodeURIComponent(profile.id)}&v=${encodeURIComponent(profile.image)}`;
15
18
  }
16
19
  /** Makes a profile, in use unless `use` is false, with the photo after it, made small first so that a photo that cannot be read makes no profile: the refusal, or undefined. */
17
- export async function makeProfile({ name, level, rating, site, avatar, photo, use }) {
20
+ export async function makeProfile({ name, level, lichess, chesscom, fide, avatar, photo, use }) {
18
21
  const image = photo === undefined ? undefined : await shrunk(photo).catch(() => undefined);
19
22
  if (photo !== undefined && image === undefined) {
20
23
  return badImage;
21
24
  }
22
- const answer = await post("/api/profile/new", jsonOf({ name: name.trim(), level, ...(rating === undefined ? {} : { rating, site }), ...(avatar === undefined ? {} : { avatar }), ...(use === false ? { use } : {}) }));
25
+ const names = { ...(lichess?.trim() ? { lichess: lichess.trim() } : {}), ...(chesscom?.trim() ? { chesscom: chesscom.trim() } : {}) };
26
+ const chosen = { ...(fide === undefined ? {} : { fide }), ...(avatar === undefined ? {} : { avatar }), ...(use === false ? { use } : {}) };
27
+ const answer = await post("/api/profile/new", jsonOf({ name: name.trim(), level, ...names, ...chosen }));
23
28
  if ("refused" in answer) {
24
29
  return answer.refused;
25
30
  }
@@ -33,9 +38,9 @@ export async function useProfile(id) {
33
38
  export async function chooseAvatar(profile, avatar) {
34
39
  return refusalOf(await post(forProfile("/api/profile/avatar", profile), jsonOf({ avatar })));
35
40
  }
36
- /** The player's names on Lichess and chess.com for the profile the page shows, an empty one removed: the server's refusal, or undefined. */
37
- export async function saveAccounts(profile, accounts) {
38
- return refusalOf(await post(forProfile("/api/profile/accounts", profile), jsonOf({ lichess: accounts.lichess.trim(), chesscom: accounts.chesscom.trim() })));
41
+ /** What the player changes in the profile the page shows: an empty level or site name removed. The server's refusal, or undefined. */
42
+ export async function editProfile(profile, changes) {
43
+ return refusalOf(await post(forProfile("/api/profile/edit", profile), jsonOf(changes)));
39
44
  }
40
45
  /** Opens the data folder in the system's file manager, where the page runs: the server's refusal, or undefined. */
41
46
  export async function openDataFolder() {
@@ -30,6 +30,11 @@ export function settingsFrom(value, defaults = { theme: "system", sound: true })
30
30
  sound: typeof stored.sound === "boolean" ? stored.sound : defaults.sound,
31
31
  voice: typeof stored.voice === "boolean" ? stored.voice : false,
32
32
  language: oneOf(stored.language, ["auto", "it", "en"], "auto"),
33
+ // Checked against what the host offers when the chat opens, which this page does not know.
34
+ claudeModel: word(stored.claudeModel),
35
+ claudeEffort: word(stored.claudeEffort),
36
+ codexModel: word(stored.codexModel),
37
+ codexEffort: word(stored.codexEffort),
33
38
  };
34
39
  }
35
40
  /** Remembers the settings in this browser. */
@@ -75,3 +80,7 @@ function parsed(saved) {
75
80
  function oneOf(value, choices, fallback) {
76
81
  return choices.find((choice) => choice === value) ?? fallback;
77
82
  }
83
+ // A host's model or effort, a short word; empty when it is none.
84
+ function word(value) {
85
+ return typeof value === "string" && /^[\w.-]{1,40}$/.test(value) ? value : "";
86
+ }
@@ -5,7 +5,9 @@
5
5
  @import "board/board.css";
6
6
  @import "talk/talk.css";
7
7
  @import "talk/chat.css";
8
+ @import "table/opener.css";
8
9
  @import "game/game.css";
9
10
  @import "helps/helps.css";
10
11
  @import "legend/legend.css";
11
12
  @import "dialogs/dialogs.css";
13
+ @import "guide/guide.css";
@@ -0,0 +1,65 @@
1
+ /* The table with no chat at it (D-104): the asleep note's box, with a row for each host, its button and its choices, and the command to type instead */
2
+ .opener {
3
+ display: grid;
4
+ grid-template-columns: minmax(0, 1fr) auto auto;
5
+ gap: 8px 6px;
6
+ }
7
+
8
+ .opener > p {
9
+ grid-column: 1 / -1;
10
+ margin: 0;
11
+ }
12
+
13
+ /* One row a host, its columns shared with the other's through the subgrid: the choices as wide as their longest name, the button takes the rest, all as tall */
14
+ .opener-host {
15
+ display: grid;
16
+ grid-column: 1 / -1;
17
+ grid-template-columns: subgrid;
18
+ }
19
+
20
+ .opener-host > .command {
21
+ justify-content: center;
22
+ padding: 6px 8px;
23
+ overflow: hidden;
24
+ white-space: nowrap;
25
+ }
26
+
27
+ .opener-host > .command:disabled,
28
+ .opener-host > .command:disabled:hover {
29
+ cursor: default;
30
+ opacity: 0.5;
31
+ background: var(--accent);
32
+ border-color: var(--accent);
33
+ }
34
+
35
+ .opener-host select {
36
+ padding: 4px;
37
+ border: 1px solid var(--line);
38
+ border-radius: 6px;
39
+ background: var(--card);
40
+ color: var(--ink);
41
+ font: inherit;
42
+ font-size: 13px;
43
+ }
44
+
45
+ /* Empty, the state takes no room: its margin gives back the row's gap */
46
+ .opener-state:empty {
47
+ margin-bottom: -8px;
48
+ }
49
+
50
+ .opener-command {
51
+ color: var(--soft);
52
+ font-size: 12.5px;
53
+ }
54
+
55
+ /* Each command whole on its line; two families, so the browser does not shrink the monospace */
56
+ .opener-command code {
57
+ font-family: ui-monospace, monospace;
58
+ white-space: nowrap;
59
+ user-select: all;
60
+ }
61
+
62
+ /* Over the board, where the note lets clicks through to the squares, only its buttons, choices and commands take them */
63
+ .over-board > .opener :is(button, select, code) {
64
+ pointer-events: auto;
65
+ }
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
2
+ // The table with no chat at it (D-104): a button for each host installed, which opens a terminal with a chat at the table, the model and effort it plays
3
+ // with beside it, kept in the profile, and the command to type in a terminal instead.
4
+ import { useState } from "preact/hooks";
5
+ /** Where the asleep note stands while no chat is at the table: the hosts that open one, their choices, and the command to type. */
6
+ export function ChatOpener({ table, settings, onChange, name, text }) {
7
+ const [sending, setSending] = useState(false);
8
+ const [failed, setFailed] = useState(false);
9
+ const words = text.table;
10
+ const installed = table.hosts.filter((host) => host.installed && host.name in choiceKeys);
11
+ const busy = sending || table.opening !== undefined;
12
+ const open = async (host) => {
13
+ setSending(true);
14
+ setFailed(false);
15
+ const opened = await openChat(host);
16
+ setSending(false);
17
+ setFailed(!opened);
18
+ };
19
+ // The chat started again for a new game needs nothing of the player.
20
+ if (table.opening === "again") {
21
+ return _jsx("p", { class: "asleep", role: "status", children: words.again(name) });
22
+ }
23
+ if (installed.length === 0) {
24
+ return _jsx("p", { class: "asleep", role: "status", children: words.install(name) });
25
+ }
26
+ // The state stays in the page, empty when there is none, so a screen reader hears it change.
27
+ return (_jsxs("section", { class: "asleep opener", "aria-label": words.label, children: [_jsx("p", { children: words.noChat(name) }), installed.map((host) => (_jsxs("div", { class: "opener-host", children: [_jsx("button", { type: "button", class: "command primary", disabled: busy, onClick: () => void open(host.name), children: hostTitles[host.name] ?? host.name }), _jsx(Choice, { host: host, kind: "model", settings: settings, onChange: onChange, text: text }), _jsx(Choice, { host: host, kind: "effort", settings: settings, onChange: onChange, text: text })] }, host.name))), _jsx("p", { class: "opener-state", role: "status", children: busy ? words.opening : failed ? words.failed : null }), _jsxs("p", { class: "opener-command", children: [words.typeIt, " ", installed.map((host, index) => (_jsxs("span", { children: [index === 0 ? "" : " · ", _jsx("code", { children: host.command })] }, host.name)))] })] }));
28
+ }
29
+ const hostTitles = { claude: "Claude Code", codex: "Codex" };
30
+ // The settings that keep each host's choice.
31
+ const choiceKeys = {
32
+ claude: { model: "claudeModel", effort: "claudeEffort" },
33
+ codex: { model: "codexModel", effort: "codexEffort" },
34
+ };
35
+ /** A host's model or effort: a dash keeps the host's own; a choice it no longer offers shows as the dash. Its title says what it stands at, the dash too. */
36
+ function Choice({ host, kind, settings, onChange, text }) {
37
+ const key = choiceKeys[host.name][kind];
38
+ const offered = kind === "model" ? host.models : host.efforts;
39
+ const chosen = offered.includes(settings[key]) ? settings[key] : "";
40
+ const title = hostTitles[host.name] ?? host.name;
41
+ if (offered.length === 0) {
42
+ return null;
43
+ }
44
+ return (_jsxs("select", { "aria-label": `${text.table[kind]}, ${title}`, title: `${text.table[kind]}: ${chosen === "" ? text.table.asHost(title) : chosen}`, value: chosen, onChange: (event) => onChange({ ...settings, [key]: event.currentTarget.value }), children: [_jsx("option", { value: "", children: "\u2014" }), offered.map((value) => _jsx("option", { value: value, children: shortName(value) }, value))] }));
45
+ }
46
+ // Codex's models without the "gpt-" they all start with, so the choice fits beside the button in the column; the title keeps the whole name.
47
+ function shortName(value) {
48
+ return value.replace(/^gpt-/, "");
49
+ }
50
+ /** Asks the table to open a terminal with a chat in the host: whether it did. */
51
+ async function openChat(host) {
52
+ try {
53
+ const response = await fetch("/api/table/chat", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ host }) });
54
+ return response.ok && (await response.json()).opened === true;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
@@ -21,6 +21,11 @@
21
21
  }
22
22
 
23
23
  /* The thread reads in time's order whichever way the board is turned: the newest words just over the box (Zoe) */
24
+ .flipped .talk.studied,
25
+ .flipped .talk.studied > section {
26
+ flex-direction: column;
27
+ }
28
+
24
29
  .flipped .talk.studied .sent {
25
30
  justify-content: flex-end;
26
31
  margin: 0 0 8px;
@@ -71,9 +76,11 @@
71
76
  display: flex;
72
77
  align-items: center;
73
78
  gap: 1px;
74
- margin: 0 0 2px;
75
- padding: 0;
79
+ min-height: 24px;
80
+ margin: -2px 0 2px -6px;
81
+ padding: 2px 6px;
76
82
  border: 0;
83
+ border-radius: 6px;
77
84
  background: none;
78
85
  color: inherit;
79
86
  font: inherit;
@@ -86,5 +93,5 @@
86
93
  .shown-move:hover,
87
94
  .shown-move:focus-visible {
88
95
  opacity: 1;
89
- text-decoration: underline;
96
+ background: color-mix(in oklab, currentColor 15%, transparent);
90
97
  }
@@ -1,23 +1,42 @@
1
1
  /* The talk's column: the players' cards with their pictures and names, the faces, the words said and the box to write in, the card of a page offline,
2
2
  and the notes laid over the board between games */
3
3
 
4
- /* The picture stays at the card's top left, however many lines the card has; the clock in the middle */
4
+ /* The picture at the card's top left, the clock at its top right (Stefano); the pieces taken and the badges under the name, run to the card's edge, under
5
+ the clock too; the button that starts the clocks, or the next game, takes the card's width below */
5
6
  .player-line {
6
- display: flex;
7
- align-items: flex-start;
8
- gap: 12px;
7
+ display: grid;
8
+ grid-template-columns: auto minmax(0, 1fr) auto;
9
+ grid-template-rows: auto 1fr;
10
+ column-gap: 12px;
11
+ align-items: start;
12
+ }
13
+
14
+ .player-line > :first-child {
15
+ grid-column: 1;
16
+ grid-row: 1;
17
+ }
18
+
19
+ .player-line:has(> .haul) > :first-child {
20
+ grid-row: 1 / span 2;
21
+ }
22
+
23
+ .player-line > .who {
24
+ grid-column: 2;
25
+ grid-row: 1;
9
26
  }
10
27
 
11
28
  .player-line > .clock {
12
- align-self: center;
29
+ grid-column: 3;
30
+ grid-row: 1;
13
31
  }
14
32
 
15
- .player-line > svg {
16
- flex: none;
33
+ .player-line > .haul {
34
+ grid-column: 2 / -1;
35
+ grid-row: 2;
36
+ min-width: 0;
17
37
  }
18
38
 
19
39
  .who {
20
- flex: 1;
21
40
  min-width: 0;
22
41
  line-height: 1.25;
23
42
  }
@@ -76,14 +95,11 @@
76
95
 
77
96
  /* The clocks wait for the player (Zoe): the button that starts them takes a line of the player's card, under the clock it starts, off the board's squares;
78
97
  between games the new game takes the same line, in the clock's place (D-77) */
79
- .player-line:has(> .start-clocks, > .next-game) {
80
- flex-wrap: wrap;
81
- row-gap: 10px;
82
- }
83
-
84
98
  .start-clocks,
85
99
  .next-game {
86
- flex: 1 0 100%;
100
+ grid-column: 1 / -1;
101
+ grid-row: 3;
102
+ margin-top: 10px;
87
103
  justify-content: center;
88
104
  padding: 8px 14px;
89
105
  font-size: 15px;
@@ -107,7 +123,8 @@
107
123
  align-self: center;
108
124
  }
109
125
 
110
- .player-line > .who:not(:has(.note)) .taken:empty {
126
+ /* In analysis, a side that took nothing has its badges right under its name */
127
+ .haul:has(> .badge-counts) > .taken:empty {
111
128
  display: none;
112
129
  }
113
130
 
@@ -430,6 +447,12 @@
430
447
  display: none;
431
448
  }
432
449
 
450
+ /* A bubble keeps its height: one that does not fit is hidden whole, the newest scrolls in itself (talk.tsx) */
451
+ .says > li,
452
+ .sent > li {
453
+ flex: none;
454
+ }
455
+
433
456
  .say {
434
457
  position: relative;
435
458
  background: var(--say);
@@ -646,11 +669,6 @@
646
669
  margin: 8px 0 0;
647
670
  }
648
671
 
649
- /* In analysis nothing in the talk gives way: on a short screen the talk scrolls whole */
650
- .talk.studied {
651
- overflow-y: auto;
652
- }
653
-
654
672
  .talk.studied > section,
655
673
  .talk.studied > section > * {
656
674
  flex: none;
@@ -703,12 +721,6 @@
703
721
  margin-top: 4px;
704
722
  }
705
723
 
706
- /* In analysis the board turned round changes which side's card is on top, never the order of the talk */
707
- .flipped .talk.studied,
708
- .flipped .talk.studied > section {
709
- flex-direction: column;
710
- }
711
-
712
724
  .move-note .head {
713
725
  display: flex;
714
726
  align-items: center;
@@ -164,13 +164,15 @@ function useOnlyWhole(list, lines, newestFirst = false) {
164
164
  }
165
165
  const fit = () => {
166
166
  const box = element.getBoundingClientRect();
167
+ const padding = getComputedStyle(element);
168
+ const room = element.clientHeight - parseFloat(padding.paddingTop) - parseFloat(padding.paddingBottom);
167
169
  const newest = newestFirst ? element.firstElementChild : element.lastElementChild;
168
170
  for (const item of element.children) {
169
171
  const place = item.getBoundingClientRect();
170
172
  const style = item.style;
171
173
  // The newest never hides: one longer than the column, as a note with the helps on (D-78), scrolls in itself.
172
- style.maxHeight = item === newest ? box.height + "px" : "";
173
- style.overflowY = item === newest && item.scrollHeight > box.height ? "auto" : "";
174
+ style.maxHeight = item === newest ? room + "px" : "";
175
+ style.overflowY = item === newest && item.scrollHeight > room ? "auto" : "";
174
176
  style.visibility = item === newest || (place.top >= box.top - 1 && place.bottom <= box.bottom + 1) ? "" : "hidden";
175
177
  }
176
178
  };