The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): truncate cron text on Unicode boundaries
luyifan31173830438f
diff --git a/apps/desktop/src/app/cron/index.tsx b/apps/desktop/src/app/cron/index.tsxindex 459168a6cf3..445a20f770e 100644--- a/apps/desktop/src/app/cron/index.tsx+++ b/apps/desktop/src/app/cron/index.tsx@@ -86,7 +86,7 @@ import {toggleCronDeliveryTarget,validateCronEditor} from './cron-job-model'-import { jobState, jobTitle, nextRunOverdueMs, STATE_DOT } from './job-state'+import { jobState, jobTitle, nextRunOverdueMs, STATE_DOT, truncateText } from './job-state'import { openCronRun, reconcileCronRunVerdicts } from './open-cron-run'const DEFAULT_DELIVER = 'local'@@ -123,7 +123,7 @@ const STATE_TONE: Record<string, PanelPillTone> = {completed: 'muted'}-const truncate = (value: string, max = 80): string => (value.length > max ? `${value.slice(0, max)}β¦` : value)+const truncate = (value: string, max = 80): string => truncateText(value, max)function jobName(job: CronJob): string {return asText(job.name).trim()diff --git a/apps/desktop/src/app/cron/job-state.test.ts b/apps/desktop/src/app/cron/job-state.test.tsnew file mode 100644index 00000000000..eb0bc64826d--- /dev/null+++ b/apps/desktop/src/app/cron/job-state.test.ts@@ -0,0 +1,16 @@+import { describe, expect, it } from 'vitest'++import { truncateText } from './job-state'++describe('truncateText', () => {+ it('truncates on Unicode code-point boundaries', () => {+ const result = truncateText('ππππ', 3)++ expect(result).toBe('πππβ¦')+ expect(Array.from(result)).toEqual(['π', 'π', 'π', 'β¦'])+ })++ it('does not add an ellipsis at the limit', () => {+ expect(truncateText('πππ', 3)).toBe('πππ')+ })+})diff --git a/apps/desktop/src/app/cron/job-state.ts b/apps/desktop/src/app/cron/job-state.tsindex f8b08c32cd2..a6f1f7a40de 100644--- a/apps/desktop/src/app/cron/job-state.ts+++ b/apps/desktop/src/app/cron/job-state.ts@@ -19,13 +19,18 @@ export function jobState(job: CronJob): string {return state || (job.enabled === false ? 'disabled' : 'scheduled')}+export function truncateText(value: string, max: number): string {+ const codePoints = Array.from(value)++ return codePoints.length > max ? `${codePoints.slice(0, max).join('')}β¦` : value+}+// Human label for a job: name β first 60 of prompt β first 60 of script β id.// One source for the sidebar row and the Cron page so the two never drift.export function jobTitle(job: CronJob): string {const pick = (v: unknown) => (typeof v === 'string' ? v.trim() : '')- const clip = (v: string) => (v.length > 60 ? `${v.slice(0, 60)}β¦` : v)- return pick(job.name) || clip(pick(job.prompt)) || clip(pick(job.script)) || job.id || 'Cron job'+ return pick(job.name) || truncateText(pick(job.prompt), 60) || truncateText(pick(job.script), 60) || job.id || 'Cron job'}// Mirrors hermes_cli/cron.py `_OVERDUE_GRACE_SECONDS`: a busy tick can dispatch a few minutes late.