Skip to content

Commit 47ff7c1

Browse files
Fix operator UI gate issues
Co-authored-by: DanielWalnut <hetaoBackend@users.noreply.github.com>
1 parent d38aeac commit 47ff7c1

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

taskboard-electron/src/renderer/App.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,9 +2256,7 @@ function HeartbeatDetailPanel({ heartbeat, ticks, onClose }) {
22562256
useEffect(() => {
22572257
const heartbeatChanged = previousHeartbeatIdRef.current !== heartbeat.id;
22582258
previousHeartbeatIdRef.current = heartbeat.id;
2259-
setSelectedTickId((current) =>
2260-
selectTickAfterRefresh(current, ticks, heartbeatChanged),
2261-
);
2259+
setSelectedTickId((current) => selectTickAfterRefresh(current, ticks, heartbeatChanged));
22622260
}, [heartbeat.id, ticks]);
22632261

22642262
useEffect(() => {

taskboard-electron/src/renderer/operatorUi.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ test("heartbeat tick polling schedules only after the active request settles", a
4444
resolveLoad = resolve;
4545
});
4646
const applied: number[][] = [];
47+
let confirmApplied: () => void = () => {};
48+
const application = new Promise<void>((resolve) => {
49+
confirmApplied = resolve;
50+
});
4751
const scheduled: Array<() => void> = [];
4852
const cancelled: unknown[] = [];
4953

5054
const stop = startHeartbeatTickPolling({
5155
heartbeatId: 4,
52-
load: async () => loaded,
53-
onTicks: (ticks) => applied.push(ticks),
56+
load: () => loaded,
57+
onTicks: (ticks) => {
58+
applied.push(ticks);
59+
confirmApplied();
60+
},
5461
onError: () => {},
5562
schedule: (callback) => {
5663
scheduled.push(callback);
@@ -61,7 +68,7 @@ test("heartbeat tick polling schedules only after the active request settles", a
6168

6269
expect(scheduled).toHaveLength(0);
6370
resolveLoad([8, 7]);
64-
await Promise.resolve();
71+
await application;
6572
await Promise.resolve();
6673
expect(applied).toEqual([[8, 7]]);
6774
expect(scheduled).toHaveLength(1);
@@ -80,7 +87,7 @@ test("stopping heartbeat tick polling ignores an in-flight stale response", asyn
8087

8188
const stop = startHeartbeatTickPolling({
8289
heartbeatId: 4,
83-
load: async () => loaded,
90+
load: () => loaded,
8491
onTicks: (ticks) => applied.push(ticks),
8592
onError: () => {},
8693
schedule: () => {

taskboard-electron/src/renderer/operatorUi.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ type HeartbeatTickPollingOptions<T> = {
1515
};
1616

1717
export function taskNeedsResponse(question: unknown, answer: unknown): boolean {
18-
return (
19-
typeof question === "string" &&
20-
question.trim().length > 0 &&
21-
!String(answer ?? "").trim()
22-
);
18+
return typeof question === "string" && question.trim().length > 0 && !String(answer ?? "").trim();
2319
}
2420

2521
export function prepareTaskResponse(

0 commit comments

Comments
 (0)