This commit is contained in:
2026-10-17 18:25:04 +07:00
parent 701bca234e
commit d3683ac6cf
15 changed files with 124 additions and 691 deletions
+1 -4
View File
@@ -30,16 +30,14 @@ export class Controller {
state: State = { revision: 0, command: null, status: 'idle', error: '', samples: [] }
private seen = new Set<string>()
private startedAt = 0
private origin: 'computer' | 'phone' = 'computer'
constructor(private publish: (state: State) => void) {}
command(input: unknown, origin: 'computer' | 'phone' = 'computer') {
command(input: unknown) {
const command = parseCommand(input)
if (this.seen.has(command.id)) return
this.seen.add(command.id)
// shortcut: помним 4096 команд стенда; долговременная дедупликация — SCREEN-004.
if (this.seen.size > 4096) this.seen.delete(this.seen.values().next().value!)
this.startedAt = performance.now()
this.origin = origin
this.state = {
...this.state,
revision: this.state.revision + 1,
@@ -70,7 +68,6 @@ export class Controller {
...this.state.samples.slice(-399),
{
media: this.state.command.media,
origin: this.origin,
milliseconds: performance.now() - this.startedAt,
},
]