BlueGit

projects-timfalken-com microchess

Keep unfinished ended tiles in Your Turn until rematch.

Finished games stay actionable in Your Turn; requesting rematch moves the tile to Not your turn while Exit still removes it.

Co-authored-by: Cursor <cursoragent@cursor.com>

timfa Tim Falken · pushed by timfa

Authored 2026-09-10 · 2 months ago

Hash
dc87b8c047003fecdee4651b2acde4322a026325
Parent
2b06d5e2
3 files changed +7 −2
web/README.md +1 −1
@@ -62,7 +62,7 @@ Initial position, viewed from White:
62 62
63 63 White moves first. Pawns move one square, never double-step; there is no castling or en passant. Promotion is mandatory to queen, rook, bishop or knight. The server generates legal moves and checks king safety. Checkmate and stalemate are evaluated after every move. Standard insufficient material positions (bare kings, lone bishop/knight, only bishops on one square color) draw automatically. Threefold repetition and the 50-move rule can be claimed from the game menu, including using an intended legal move; fivefold repetition and 75 moves are automatic, with checkmate taking precedence. A draw can also be offered or the game resigned from your turn's menu.
64 64
65 The top grid includes your moves, incoming challenges and finished games. Opponent-turn games and sent challenges are noninteractive in the lower grid. Boards orient toward your color. Polling updates the other player every 2.5 seconds while the tab is visible. No clocks or timeouts are applied to games.
65 The top grid includes your moves, incoming challenges and finished games that still need Rematch or Exit. After you request a rematch, that tile moves to the lower grid while you wait. Opponent-turn games and sent challenges are noninteractive in the lower grid. Boards orient toward your color. Polling updates the other player every 2.5 seconds while the tab is visible. No clocks or timeouts are applied to games.
66 66
67 67 A friend invitation is valid for one month and can be accepted once. Accepting inserts one symmetric friendship; either player can remove it. Direct challenges require friendship. Match links likewise expire after one calendar month and are consumed only by acceptance; dismissing/rejecting the modal preserves the link. An expired link cannot be accepted. Both link types survive the login redirect.
68 68
@@ -62,7 +62,7 @@ Initial position, viewed from White:
62
62
63White moves first. Pawns move one square, never double-step; there is no castling or en passant. Promotion is mandatory to queen, rook, bishop or knight. The server generates legal moves and checks king safety. Checkmate and stalemate are evaluated after every move. Standard insufficient material positions (bare kings, lone bishop/knight, only bishops on one square color) draw automatically. Threefold repetition and the 50-move rule can be claimed from the game menu, including using an intended legal move; fivefold repetition and 75 moves are automatic, with checkmate taking precedence. A draw can also be offered or the game resigned from your turn's menu.
63White moves first. Pawns move one square, never double-step; there is no castling or en passant. Promotion is mandatory to queen, rook, bishop or knight. The server generates legal moves and checks king safety. Checkmate and stalemate are evaluated after every move. Standard insufficient material positions (bare kings, lone bishop/knight, only bishops on one square color) draw automatically. Threefold repetition and the 50-move rule can be claimed from the game menu, including using an intended legal move; fivefold repetition and 75 moves are automatic, with checkmate taking precedence. A draw can also be offered or the game resigned from your turn's menu.
64
64
65The top grid includes your moves, incoming challenges and finished games. Opponent-turn games and sent challenges are noninteractive in the lower grid. Boards orient toward your color. Polling updates the other player every 2.5 seconds while the tab is visible. No clocks or timeouts are applied to games.
65The top grid includes your moves, incoming challenges and finished games that still need Rematch or Exit. After you request a rematch, that tile moves to the lower grid while you wait. Opponent-turn games and sent challenges are noninteractive in the lower grid. Boards orient toward your color. Polling updates the other player every 2.5 seconds while the tab is visible. No clocks or timeouts are applied to games.
66
66
67A friend invitation is valid for one month and can be accepted once. Accepting inserts one symmetric friendship; either player can remove it. Direct challenges require friendship. Match links likewise expire after one calendar month and are consumed only by acceptance; dismissing/rejecting the modal preserves the link. An expired link cannot be accepted. Both link types survive the login redirect.
67A friend invitation is valid for one month and can be accepted once. Accepting inserts one symmetric friendship; either player can remove it. Direct challenges require friendship. Match links likewise expire after one calendar month and are consumed only by acceptance; dismissing/rejecting the modal preserves the link. An expired link cannot be accepted. Both link types survive the login redirect.
68
68
web/assets/app.js +1 −1
@@ -133,7 +133,7 @@ function renderGames ()
133 133 const animate = !matchMedia('(prefers-reduced-motion: reduce)').matches &&
134 134 (relocating || [...document.querySelectorAll(selector)].some(el => el.getAnimations().length));
135 135 const before = new Map(animate ? [...document.querySelectorAll(selector)].map(el => [key(el), el.getBoundingClientRect()]) : []);
136 const yours = state.games.filter(g => g.yourTurn || g.status === 'ended' || g.status === 'pending' && g.incoming || moveHolds.has(g.id)).sort((a, b) => (moveHolds.get(a.id)?.turnOrder ?? a.turnOrder) - (moveHolds.get(b.id)?.turnOrder ?? b.turnOrder) || a.id - b.id);
136 const yours = state.games.filter(g => g.yourTurn || g.status === 'ended' && !g.rematch || g.status === 'pending' && g.incoming || moveHolds.has(g.id)).sort((a, b) => (moveHolds.get(a.id)?.turnOrder ?? a.turnOrder) - (moveHolds.get(b.id)?.turnOrder ?? b.turnOrder) || a.id - b.id);
137 137 const waiting = state.games.filter(g => !yours.includes(g));
138 138 $('#your-count').textContent = yours.length; $('#waiting-count').textContent = waiting.length + (state.matchmaking ? 1 : 0);
139 139 // Continue from the visible fill even when polling/selection recreates the cards mid-animation.
@@ -133,7 +133,7 @@ function renderGames ()
133 const animate = !matchMedia('(prefers-reduced-motion: reduce)').matches &&
133 const animate = !matchMedia('(prefers-reduced-motion: reduce)').matches &&
134 (relocating || [...document.querySelectorAll(selector)].some(el => el.getAnimations().length));
134 (relocating || [...document.querySelectorAll(selector)].some(el => el.getAnimations().length));
135 const before = new Map(animate ? [...document.querySelectorAll(selector)].map(el => [key(el), el.getBoundingClientRect()]) : []);
135 const before = new Map(animate ? [...document.querySelectorAll(selector)].map(el => [key(el), el.getBoundingClientRect()]) : []);
136 const yours = state.games.filter(g => g.yourTurn || g.status === 'ended' || g.status === 'pending' && g.incoming || moveHolds.has(g.id)).sort((a, b) => (moveHolds.get(a.id)?.turnOrder ?? a.turnOrder) - (moveHolds.get(b.id)?.turnOrder ?? b.turnOrder) || a.id - b.id);
136 const yours = state.games.filter(g => g.yourTurn || g.status === 'ended' && !g.rematch || g.status === 'pending' && g.incoming || moveHolds.has(g.id)).sort((a, b) => (moveHolds.get(a.id)?.turnOrder ?? a.turnOrder) - (moveHolds.get(b.id)?.turnOrder ?? b.turnOrder) || a.id - b.id);
137 const waiting = state.games.filter(g => !yours.includes(g));
137 const waiting = state.games.filter(g => !yours.includes(g));
138 $('#your-count').textContent = yours.length; $('#waiting-count').textContent = waiting.length + (state.matchmaking ? 1 : 0);
138 $('#your-count').textContent = yours.length; $('#waiting-count').textContent = waiting.length + (state.matchmaking ? 1 : 0);
139 // Continue from the visible fill even when polling/selection recreates the cards mid-animation.
139 // Continue from the visible fill even when polling/selection recreates the cards mid-animation.
web/tests/browser.mjs +5 −0
@@ -156,6 +156,8 @@ try{
156 156 assert.equal(await page.locator('.end-content').evaluate(e=>getComputedStyle(e).opacity),'1','Hover reveals result controls');
157 157 }
158 158 assert.equal(await white.evaluate(()=>window.savedFlights),1,'Finished game animates to history once');
159 assert.equal(await white.locator(`#your-games [data-game="${id}"]`).count(),1,'Finished game stays in Your Turn');
160 assert.equal(await black.locator(`#your-games [data-game="${id}"]`).count(),1,'Opponent finished game also stays in Your Turn');
159 161 await white.locator('#history-button').click();
160 162 await white.locator('.history-entry').waitFor();
161 163 await white.locator('.history-entry').first().click();
@@ -203,7 +205,10 @@ try{
203 205 await white.evaluate(()=>refresh(true));
204 206 assert.equal(await white.locator('.saved-hourglass').count(),0,'Saved animation does not repeat');
205 207 await white.getByRole('button',{name:'Rematch',exact:true}).click();
208 await white.locator(`#waiting-games [data-game="${id}"]`).waitFor();
209 assert.equal(await white.locator(`#your-games [data-game="${id}"]`).count(),0,'Requested rematch leaves Your Turn');
206 210 await black.getByText(/wants a rematch/).waitFor();
211 assert.equal(await black.locator(`#your-games [data-game="${id}"]`).count(),1,'Opponent rematch offer stays in Your Turn');
207 212 await black.getByRole('button',{name:'Rematch',exact:true}).click();
208 213 await white.locator('.board').waitFor();
209 214 assert.equal((await state(white)).games[0].color,'b','Rematch flips colors');
@@ -156,6 +156,8 @@ try{
156 assert.equal(await page.locator('.end-content').evaluate(e=>getComputedStyle(e).opacity),'1','Hover reveals result controls');
156 assert.equal(await page.locator('.end-content').evaluate(e=>getComputedStyle(e).opacity),'1','Hover reveals result controls');
157 }
157 }
158 assert.equal(await white.evaluate(()=>window.savedFlights),1,'Finished game animates to history once');
158 assert.equal(await white.evaluate(()=>window.savedFlights),1,'Finished game animates to history once');
159 assert.equal(await white.locator(`#your-games [data-game="${id}"]`).count(),1,'Finished game stays in Your Turn');
160 assert.equal(await black.locator(`#your-games [data-game="${id}"]`).count(),1,'Opponent finished game also stays in Your Turn');
159 await white.locator('#history-button').click();
161 await white.locator('#history-button').click();
160 await white.locator('.history-entry').waitFor();
162 await white.locator('.history-entry').waitFor();
161 await white.locator('.history-entry').first().click();
163 await white.locator('.history-entry').first().click();
@@ -203,7 +205,10 @@ try{
203 await white.evaluate(()=>refresh(true));
205 await white.evaluate(()=>refresh(true));
204 assert.equal(await white.locator('.saved-hourglass').count(),0,'Saved animation does not repeat');
206 assert.equal(await white.locator('.saved-hourglass').count(),0,'Saved animation does not repeat');
205 await white.getByRole('button',{name:'Rematch',exact:true}).click();
207 await white.getByRole('button',{name:'Rematch',exact:true}).click();
208 await white.locator(`#waiting-games [data-game="${id}"]`).waitFor();
209 assert.equal(await white.locator(`#your-games [data-game="${id}"]`).count(),0,'Requested rematch leaves Your Turn');
206 await black.getByText(/wants a rematch/).waitFor();
210 await black.getByText(/wants a rematch/).waitFor();
211 assert.equal(await black.locator(`#your-games [data-game="${id}"]`).count(),1,'Opponent rematch offer stays in Your Turn');
207 await black.getByRole('button',{name:'Rematch',exact:true}).click();
212 await black.getByRole('button',{name:'Rematch',exact:true}).click();
208 await white.locator('.board').waitFor();
213 await white.locator('.board').waitFor();
209 assert.equal((await state(white)).games[0].color,'b','Rematch flips colors');
214 assert.equal((await state(white)).games[0].color,'b','Rematch flips colors');