Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion skills/comms-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ tdc users --ids-only # Output only user IDs
tdc status # Show your status (default login is enough)
tdc status --json # Show it as { status } JSON (null when unset; --full for the whole user)
tdc status set "Deep work" --emoji 🎯 --for 2h --pause-notifications # Set supported fields (needs --full-access)
tdc status set --emoji 🤒 --for 1d # Emoji-only status: leave the message out (a status needs a message, an emoji or both)
tdc status set "On holiday" --pause-activity # Pause Todoist Karma and streaks while it is active (independent of --pause-notifications)
tdc status set "On holiday" --until 2026-10-20T09:00 # End at a date (YYYY-MM-DD, YYYY-MM-DDTHH:MM or a full ISO 8601 timestamp; local time unless it has Z or an offset)
tdc status set "Away" --dry-run # Preview without setting
Expand Down Expand Up @@ -328,7 +329,7 @@ All group *writes* (`groups create`, `rename`, `delete`, `add-user`, `remove-use

`tdc status set` and `tdc status clear` need the `user:write` scope, which only `tdc auth login --full-access` grants. `tdc status` (show) works on a default login.

`tdc status set` replaces the fields this CLI supports: omitted emoji, expiration and pause flags clear those values, while other fields and effects are preserved.
`tdc status set` replaces the fields this CLI supports: an omitted message, emoji, expiration or pause flag clears that value, while other fields and effects are preserved. Give a message, an `--emoji` or both; with neither it fails with `MISSING_CONTENT`.

Only pass `--pause-notifications` when the user asks for it. It holds back Comms notifications only for now: each app has to read the status and hold its own notifications back, and Todoist does not yet. Held notifications are not sent later.

Expand Down
10 changes: 6 additions & 4 deletions src/commands/status/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Examples:
.action(showStatus)

status
.command('set <message>')
.command('set [message]')
.description('Set your status, replacing its message, emoji, expiration, and pause effects')
.option('--emoji <emoji>', 'Emoji to show next to the message')
.option('--emoji <emoji>', 'Emoji to show next to the message, or on its own without one')
.option(
'--until <datetime>',
'When the status ends: YYYY-MM-DD, YYYY-MM-DDTHH:MM or a full ISO 8601 timestamp. Local time unless it has Z or an offset',
Expand All @@ -43,17 +43,19 @@ Examples:
.addHelpText(
'after',
`
The message is 1 to 80 characters. The status is shared with your Todoist account.
A status needs a message, an emoji or both. The message is 1 to 80 characters.
The status is shared with your Todoist account.
Setting or clearing it needs the user:write scope, so log in with tdc auth login --full-access.
--pause-notifications only affects Comms for now. Each app has to read the status and hold
its own notifications back, and Todoist does not yet. Held notifications are not sent later.
--pause-activity protects your Todoist Karma and streaks. It does not hold back notifications,
and --pause-notifications does not protect Karma, so pass both if you want both.
Omitted emoji, expiration, and pause flags clear those values. Other fields and effects are preserved.
An omitted message, emoji, expiration, or pause flag clears that value. Other fields and effects are preserved.

Examples:
tdc status set "On holiday" --emoji 🏝️ --until 2026-10-20T09:00
tdc status set "Deep work" --emoji 🎯 --for 2h --pause-notifications
tdc status set --emoji 🤒 --for 1d
tdc status set "On holiday" --emoji 🏝️ --until 2026-10-30 --pause-activity`,
)
.action(setStatus)
Expand Down
23 changes: 19 additions & 4 deletions src/commands/status/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ type SetStatusOptions = MutationOptions & {
pauseActivity?: boolean
}

function resolveMessage(message: string): string {
function resolveMessage(message: string | undefined): string | undefined {
if (message === undefined) {
return undefined
}
const trimmed = message.trim()
const length = [...trimmed].length
if (length < 1 || length > MAX_MESSAGE_LENGTH) {
throw new CliError(
'INVALID_VALUE',
`The message must be 1 to ${MAX_MESSAGE_LENGTH} characters`,
length < 1
? ['To set only an emoji, leave the message out: --emoji <emoji>']
: undefined,
)
}
return trimmed
Expand Down Expand Up @@ -81,13 +87,22 @@ function resolveExpiry(options: SetStatusOptions): Date | undefined {
return expiry
}

export async function setStatus(message: string, options: SetStatusOptions): Promise<void> {
export async function setStatus(
message: string | undefined,
options: SetStatusOptions,
): Promise<void> {
const text = resolveMessage(message)
const emoji = resolveEmoji(options.emoji)
if (text === undefined && emoji === undefined) {
throw new CliError('MISSING_CONTENT', 'A status needs a message, an emoji or both', [
'tdc status set "Deep work"',
'tdc status set --emoji 🎯',
])
}
const activeUntil = resolveExpiry(options)

const args: SetStatusArgs = {
message: text,
message: text ?? null,
emoji: emoji ?? null,
activeUntil: activeUntil ?? null,
effects: {
Expand All @@ -98,7 +113,7 @@ export async function setStatus(message: string, options: SetStatusOptions): Pro

if (options.dryRun) {
printDryRun('set status', {
Message: text,
Message: text ?? 'cleared',
Emoji: emoji ?? 'cleared',
Until: activeUntil ? formatDateTime(activeUntil) : 'cleared',
'Pause notifications': options.pauseNotifications ? 'yes' : 'cleared',
Expand Down
50 changes: 50 additions & 0 deletions src/commands/status/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,56 @@ describe('tdc status', () => {
status: { message: 'Away', emoji: null },
})
})

describe('with only an emoji', () => {
it('sends a null message and prints the emoji', async () => {
const spy = captureConsole('log')
await run('set', '--emoji', '🤒', '--for', '1d', '--pause-activity')
expect(users.setStatus).toHaveBeenCalledWith({
message: null,
emoji: '🤒',
activeUntil: new Date('2026-10-15T12:00:00.000Z'),
effects: { pauseNotifications: null, pauseActivity: {} },
})
expect(logged(spy)).toBe('Status set: 🤒')
})

it('prints a null message in JSON', async () => {
const spy = captureConsole('log')
await run('set', '--emoji', '🤒', '--json')
expect(JSON.parse(logged(spy))).toEqual({
status: { message: null, emoji: '🤒' },
})
})

it('previews the message as cleared on --dry-run', async () => {
const spy = captureConsole('log')
await run('set', '--emoji', '🤒', '--dry-run')
expect(users.setStatus).not.toHaveBeenCalled()
const out = logged(spy)
expect(out).toContain('Message: cleared')
expect(out).toContain('Emoji: 🤒')
})

it.each([[[]], [['--for', '2h', '--pause-notifications']]])(
'fails with MISSING_CONTENT before calling the API when %j gives neither a message nor an emoji',
async (flags) => {
const error = await run('set', ...flags).catch((e) => e)
expect(error).toMatchObject({
code: 'MISSING_CONTENT',
message: expect.stringContaining('message, an emoji or both'),
})
expect(users.setStatus).not.toHaveBeenCalled()
},
)

it('rejects an explicitly empty message, pointing at leaving it out', async () => {
const error = await run('set', '', '--emoji', '🤒').catch((e) => e)
expect(error.code).toBe('INVALID_VALUE')
expect(error.hints.join(' ')).toContain('leave the message out')
expect(users.setStatus).not.toHaveBeenCalled()
})
})
})

describe('clear', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/skills/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ tdc users --ids-only # Output only user IDs
tdc status # Show your status (default login is enough)
tdc status --json # Show it as { status } JSON (null when unset; --full for the whole user)
tdc status set "Deep work" --emoji 🎯 --for 2h --pause-notifications # Set supported fields (needs --full-access)
tdc status set --emoji 🤒 --for 1d # Emoji-only status: leave the message out (a status needs a message, an emoji or both)
tdc status set "On holiday" --pause-activity # Pause Todoist Karma and streaks while it is active (independent of --pause-notifications)
tdc status set "On holiday" --until 2026-10-20T09:00 # End at a date (YYYY-MM-DD, YYYY-MM-DDTHH:MM or a full ISO 8601 timestamp; local time unless it has Z or an offset)
tdc status set "Away" --dry-run # Preview without setting
Expand Down Expand Up @@ -332,7 +333,7 @@ All group *writes* (\`groups create\`, \`rename\`, \`delete\`, \`add-user\`, \`r

\`tdc status set\` and \`tdc status clear\` need the \`user:write\` scope, which only \`tdc auth login --full-access\` grants. \`tdc status\` (show) works on a default login.

\`tdc status set\` replaces the fields this CLI supports: omitted emoji, expiration and pause flags clear those values, while other fields and effects are preserved.
\`tdc status set\` replaces the fields this CLI supports: an omitted message, emoji, expiration or pause flag clears that value, while other fields and effects are preserved. Give a message, an \`--emoji\` or both; with neither it fails with \`MISSING_CONTENT\`.

Only pass \`--pause-notifications\` when the user asks for it. It holds back Comms notifications only for now: each app has to read the status and hold its own notifications back, and Todoist does not yet. Held notifications are not sent later.

Expand Down
Loading