From a3b5ed2f7a2710870343558d385dd3693bfed5d2 Mon Sep 17 00:00:00 2001 From: Scott Lovegrove Date: Tue, 17 Nov 2026 11:04:53 +0000 Subject: [PATCH] fix(status): show a status that has only an emoji MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A status can now be just an emoji, and the API returns it with a null message. @todoist/comms-sdk 5.0.1 rejected that response outright, so one user with an emoji-only status broke every command that loads workspace users, including `tdc thread view`. @todoist/comms-sdk 5.2.2 accepts it, and formatStatus now joins the emoji and message it has, instead of printing "🎯 null". --- package-lock.json | 8 ++++---- package.json | 2 +- src/commands/status/status.test.ts | 20 ++++++++++++++++++++ src/lib/status.ts | 7 +++++-- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0179c29..57ada9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@pnpm/tabtab": "0.5.4", "@todoist/cli-core": "2.0.0", - "@todoist/comms-sdk": "5.0.1", + "@todoist/comms-sdk": "5.2.2", "chalk": "5.6.2", "commander": "14.0.3", "marked": "18.0.3", @@ -2717,9 +2717,9 @@ } }, "node_modules/@todoist/comms-sdk": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@todoist/comms-sdk/-/comms-sdk-5.0.1.tgz", - "integrity": "sha512-x9OtetYxD2EAniyrxelwKyfTyMG0oXqNpIB3yF4iOg467i/71PGf2jUTEoarDfw0bhyas44wrs0imlBRpW1Low==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/@todoist/comms-sdk/-/comms-sdk-5.2.2.tgz", + "integrity": "sha512-u2SGZzAAgmw1u1XkzTg5NNvZlLlygLxra7PP9UtTFmG8dafoCPLnBcxKgBHStDiRJnFbP6dp60Yl3islNuEwsw==", "license": "MIT", "dependencies": { "@doist/sdk-kmp": "0.6.0", diff --git a/package.json b/package.json index 95ce52c..ecae2ec 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "dependencies": { "@pnpm/tabtab": "0.5.4", "@todoist/cli-core": "2.0.0", - "@todoist/comms-sdk": "5.0.1", + "@todoist/comms-sdk": "5.2.2", "chalk": "5.6.2", "commander": "14.0.3", "marked": "18.0.3", diff --git a/src/commands/status/status.test.ts b/src/commands/status/status.test.ts index 5701ebc..550958e 100644 --- a/src/commands/status/status.test.ts +++ b/src/commands/status/status.test.ts @@ -64,6 +64,26 @@ describe('tdc status', () => { expect(logged(spy)).toBe('🎯 Deep work (notifications paused)') }) + // A status can be just an emoji, which the API returns with a null or absent message. + it.each([ + ['null', { message: null, emoji: '🎯' }, '🎯'], + ['absent', { emoji: '🎯' }, '🎯'], + [ + 'null, with a pause', + { + message: null, + emoji: '🎯', + effects: { pauseNotifications: { scope: { mode: 'all' } } }, + }, + '🎯 (notifications paused)', + ], + ])('prints an emoji-only status whose message is %s', async (_name, status, expected) => { + apiMocks.getSessionUser.mockResolvedValue({ status }) + const spy = captureConsole('log') + await run('show') + expect(logged(spy)).toBe(expected) + }) + it('names each paused effect, notifications first', async () => { apiMocks.getSessionUser.mockResolvedValue({ status: { diff --git a/src/lib/status.ts b/src/lib/status.ts index 9bf0599..16cbcf8 100644 --- a/src/lib/status.ts +++ b/src/lib/status.ts @@ -1,9 +1,12 @@ import type { UserStatus } from '@todoist/comms-sdk' import { formatDateTime } from './dates.js' -/** One line for a status: emoji and message, then the expiry and the pause when they apply. */ +/** + * One line for a status: emoji and message, then the expiry and the pause when they apply. + * A status has a message, an emoji or both. + */ export function formatStatus(status: UserStatus): string { - const parts = [status.emoji ? `${status.emoji} ${status.message}` : status.message] + const parts = [[status.emoji, status.message].filter(Boolean).join(' ')] if (status.activeUntil) { parts.push(`until ${formatDateTime(new Date(status.activeUntil))}`) }