Skip to content

Commit 0c70fc3

Browse files
committed
chore(thread): remove --from-file mutation option
1 parent 71daa16 commit 0c70fc3

File tree

4 files changed

+4
-88
lines changed

4 files changed

+4
-88
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,17 @@ Run `tw --help` or `tw <command> --help` for more options.
5858

5959
## Inbox State Workflows
6060

61-
Thread inbox-state commands support single refs, bulk refs, and file input:
61+
Thread inbox-state commands support single refs and bulk refs:
6262

6363
```bash
6464
tw thread reopen 123 456 --yes # bulk reopen
65-
tw thread unread --from-file ids.txt --yes # refs from file
6665
tw thread restore 123 --unread --json # reopen + unread with JSON output
6766
tw thread done 123 --dry-run # preview archive operation
6867
```
6968

7069
Each mutation command supports:
7170

7271
```bash
73-
--from-file <path> # one thread ref per line
7472
--yes # skip bulk confirmation
7573
--dry-run # preview without changing state
7674
--json # include before/after state per thread

src/__tests__/thread.test.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { mkdtemp, writeFile } from 'node:fs/promises'
2-
import { tmpdir } from 'node:os'
3-
import { join } from 'node:path'
41
import { Command } from 'commander'
52
import { beforeEach, describe, expect, it, vi } from 'vitest'
63

@@ -291,62 +288,6 @@ describe('thread reversible inbox mutations', () => {
291288
logSpy.mockRestore()
292289
})
293290

294-
it('supports loading refs from --from-file', async () => {
295-
const fake = createFakeThreadClient({
296-
threads: [
297-
{
298-
id: 100,
299-
title: 'Thread 100',
300-
channelId: 10,
301-
workspaceId: 1,
302-
isArchived: false,
303-
inInbox: true,
304-
closed: null,
305-
lastUpdated: new Date('2026-03-03T17:00:00.000Z'),
306-
lastObjIndex: 4,
307-
},
308-
{
309-
id: 101,
310-
title: 'Thread 101',
311-
channelId: 10,
312-
workspaceId: 1,
313-
isArchived: false,
314-
inInbox: true,
315-
closed: null,
316-
lastUpdated: new Date('2026-03-03T17:00:00.000Z'),
317-
lastObjIndex: 6,
318-
},
319-
],
320-
unreadByWorkspace: { 1: [101] },
321-
})
322-
apiMocks.getTwistClient.mockResolvedValue(fake.client)
323-
324-
const dir = await mkdtemp(join(tmpdir(), 'tw-thread-'))
325-
const refsFile = join(dir, 'refs.txt')
326-
await writeFile(refsFile, '100\n101\n')
327-
328-
const program = createProgram()
329-
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {})
330-
331-
await program.parseAsync([
332-
'node',
333-
'tw',
334-
'thread',
335-
'unread',
336-
'--from-file',
337-
refsFile,
338-
'--yes',
339-
'--json',
340-
])
341-
342-
const output = parseLastJsonLog(logSpy)
343-
expect(output.results).toHaveLength(2)
344-
expect(output.errors).toEqual([])
345-
expect(output.results.every((r) => r.after.isUnread === true)).toBe(true)
346-
347-
logSpy.mockRestore()
348-
})
349-
350291
it('supports dry-run without mutating thread state', async () => {
351292
const fake = createFakeThreadClient({
352293
threads: [

src/commands/thread/mutate.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { readFile } from 'node:fs/promises'
21
import { createInterface } from 'node:readline/promises'
32
import type { TwistApi } from '@doist/twist-sdk'
43
import { Command } from 'commander'
@@ -10,7 +9,6 @@ import { resolveThreadId } from '../../lib/refs.js'
109
import { pluralize } from './helpers.js'
1110

1211
type ThreadMutationOptions = MutationOptions & {
13-
fromFile?: string
1412
yes?: boolean
1513
json?: boolean
1614
}
@@ -155,25 +153,6 @@ async function getUnreadThreadIds(client: TwistApi, workspaceId: number): Promis
155153
return new Set(unread.map((item) => item.threadId))
156154
}
157155

158-
async function loadThreadRefs(
159-
fromArgs: string[] | undefined,
160-
fromFilePath?: string,
161-
): Promise<string[]> {
162-
const refs = [...(fromArgs ?? [])]
163-
164-
if (!fromFilePath) {
165-
return refs
166-
}
167-
168-
const fileContent = await readFile(fromFilePath, 'utf8')
169-
const fromFile = fileContent
170-
.split(/\r?\n/)
171-
.map((line) => line.trim())
172-
.filter((line) => line !== '' && !line.startsWith('#'))
173-
174-
return [...refs, ...fromFile]
175-
}
176-
177156
async function confirmBulkMutation(count: number, mutationLabel: string): Promise<boolean> {
178157
if (count <= 1) {
179158
return true
@@ -282,10 +261,10 @@ async function executeThreadMutation(
282261
mutation: ThreadMutation,
283262
mutationLabel: string,
284263
): Promise<void> {
285-
const inputRefs = await loadThreadRefs(refs, options.fromFile)
264+
const inputRefs = [...(refs ?? [])]
286265

287266
if (inputRefs.length === 0) {
288-
throw new Error('No thread references provided. Pass refs and/or --from-file.')
267+
throw new Error('No thread references provided.')
289268
}
290269

291270
if (inputRefs.length > 1 && !options.dryRun && !options.yes) {
@@ -361,7 +340,6 @@ async function executeThreadMutation(
361340

362341
export function withThreadMutationOptions(command: Command): Command {
363342
return command
364-
.option('--from-file <path>', 'Read thread refs from file (one ref per line)')
365343
.option('--yes', 'Skip confirmation for bulk operations')
366344
.option('--dry-run', 'Show what would happen without executing')
367345
.option('--json', 'Output mutation results as JSON')

src/lib/skills/content.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,10 @@ tw thread read <ref> # Mark thread as read
6464
tw thread unread <ref> # Mark thread as unread
6565
tw thread restore <ref> --unread # Reopen and mark unread
6666
tw thread reopen 123 456 --yes # Bulk operation with multiple refs
67-
tw thread unread --from-file ids.txt --yes # Load refs from file
6867
\`\`\`
6968
7069
Default \`--notify\` is EVERYONE_IN_THREAD. Options: EVERYONE, EVERYONE_IN_THREAD, or comma-separated user ID refs.
71-
Thread mutation commands (\`done\`, \`reopen\`, \`read\`, \`unread\`, \`restore\`) support \`--from-file\`, \`--yes\`, \`--dry-run\`, and \`--json\`.
70+
Thread mutation commands (\`done\`, \`reopen\`, \`read\`, \`unread\`, \`restore\`) support \`--yes\`, \`--dry-run\`, and \`--json\`.
7271
7372
## Conversations (DMs/Groups)
7473

0 commit comments

Comments
 (0)