Browse Source

Polish job board launch age labels

Alvin Unreal 2 months ago
parent
commit
3475a1dd71
2 changed files with 6 additions and 2 deletions
  1. 1 0
      src/utils/background-job-board.test.ts
  2. 5 2
      src/utils/background-job-board.ts

+ 1 - 0
src/utils/background-job-board.test.ts

@@ -165,6 +165,7 @@ describe('BackgroundJobBoard', () => {
       terminalUnreconciled: false,
       completedAt: undefined,
       resultSummary: undefined,
+      launchedAt: 100,
       lastLaunchedAt: 300,
       updatedAt: 300,
     });

+ 5 - 2
src/utils/background-job-board.ts

@@ -183,7 +183,10 @@ export class BackgroundJobBoard {
     return this.list(parentSessionID).some((job) => job.terminalUnreconciled);
   }
 
-  formatForPrompt(parentSessionID: string, now = Date.now()): string | undefined {
+  formatForPrompt(
+    parentSessionID: string,
+    now = Date.now(),
+  ): string | undefined {
     const jobs = this.list(parentSessionID).filter(
       (job) => job.state === 'running' || job.terminalUnreconciled,
     );
@@ -223,7 +226,7 @@ function formatJob(job: BackgroundJobRecord, now = Date.now()): string {
   const isResume = job.lastLaunchedAt !== job.launchedAt;
   const ageLabel =
     job.state === 'running' && ageMs < 30_000
-      ? ` [${isResume ? 'resumed' : 'just launched'}, ${Math.round(ageMs / 1000)}s ago]`
+      ? ` [${isResume ? 'resumed' : 'just launched'}, ${Math.floor(ageMs / 1000)}s ago]`
       : '';
   const status = job.terminalUnreconciled
     ? `${job.state}, unreconciled`