perf(ui): reuse hint result as move preview, skip redundant evaluate
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 53s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m9s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 53s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m9s
Taking a hint auto-placed the suggested tiles and then called recompute(), which round-trips a debounced evaluate for that exact placement. The hint is the engine's own top-ranked, fully scored legal move, so its move already carries the score, words and direction an evaluate would return — the second call was pure duplicate work and added a visible disabled->enabled flicker on the submit button over slow links. Seed the move preview directly from the hint move via previewFromHint and cancel any pending evaluate timer so a stale one cannot clobber it. A later manual edit re-arms recompute() as before, so rearranged tiles are re-evaluated normally. Client-only; no backend, wire or schema change.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
newPlacement,
|
||||
place,
|
||||
placementFromHint,
|
||||
previewFromHint,
|
||||
rackView,
|
||||
recallAt,
|
||||
recallIndex,
|
||||
@@ -105,6 +106,24 @@ describe('placementFromHint', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('previewFromHint', () => {
|
||||
it('reuses the hint move as a legal preview, carrying score, words and direction', () => {
|
||||
const preview = previewFromHint({
|
||||
player: 0,
|
||||
action: 'play',
|
||||
dir: 'V',
|
||||
mainRow: 7,
|
||||
mainCol: 7,
|
||||
tiles: [{ row: 7, col: 7, letter: 'C', blank: false }],
|
||||
words: ['CAT', 'AN'],
|
||||
count: 0,
|
||||
score: 18,
|
||||
total: 42,
|
||||
});
|
||||
expect(preview).toEqual({ legal: true, score: 18, words: ['CAT', 'AN'], dir: 'V' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('reorderIndices', () => {
|
||||
it('lifts an element and drops it at the given slot among the others', () => {
|
||||
expect(reorderIndices(4, 0, 2)).toEqual([1, 2, 0, 3]);
|
||||
|
||||
Reference in New Issue
Block a user