Skip to content

feat(conversation): add tdc conversation mark-unread - #148

Merged
scottlovegrove merged 3 commits into
scottl/conversation-mark-readfrom
scottl/conversation-mark-unread
Dec 4, 2026
Merged

scottlovegrove merged 3 commits into
scottl/conversation-mark-readfrom
scottl/conversation-mark-unread

Conversation

@scottlovegrove

@scottlovegrove scottlovegrove commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Adds tdc conversation mark-unread, the inverse of tdc conversation mark-read from the PR below, on the same read-state runner and with the options of tdc thread mark-unread: one or more refs or --stdin, --yes for a bulk run, --dry-run, --json rows, and --from <message-ref> for a single conversation.

The default differs from the thread command on purpose. A conversation's unread marker is its first unread message (the backend's mark_read moves it to N+1, new messages set it to their own index, and mark_unread rejects anything below 0). comms-web's "Mark unread" on a message sends that message's index, and "Mark unread" on a whole conversation sends the latest message's index, so only the newest message turns unread. This command does the same: without --from it marks the latest message unread rather than sending the reader back to the start of what may be years of DM history; with --from it marks that message and everything after it unread. A conversation already unread from that message or an earlier one is reported and left alone.

The --json rows are { id, isRead: false, lastReadObjIndex }, where lastReadObjIndex is the last message still read (-1 when every message is unread), so the field means the same as in the thread rows. --from checks the message belongs to the conversation (INVALID_REF otherwise) and refuses more than one conversation (CONFLICTING_OPTIONS), as the thread version does.

Checked against the real API with --dry-run only, with and without --from: the message lookup, the conversation check and the index all came back as expected. Nothing was actually marked unread.

@scottlovegrove
scottlovegrove added this pull request to stack #146 December 4, 2026 14:44
@scottlovegrove scottlovegrove self-assigned this Dec 4, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds tdc conversation mark-unread on the shared read-state runner, mirroring the thread version's options and guards while intentionally defaulting to marking the latest message unread — no inline issues were flagged.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (2)
  • P3 src/commands/conversation/mark-unread.ts:77: resolveFromObjIndex is a near-verbatim copy of the one in src/commands/thread/unread.ts — same ref parsing, same two INVALID_REF checks with reworded messages, same typeof objIndex !== 'number' guard — differing only in the lookup call (conversationMessages.getMessage vs comments.getComment), the parent field (conversationId vs threadId), and the final index adjustment. This is now the second copy, so it's worth folding into one helper (e.g. in src/lib/read-state.ts) parameterized by the lookup, parent field, noun for the messages, and an optional index offset. Not blocking.
  • P3 src/commands/conversation/conversation.test.ts:2274: There's no test for a --from message that has no objIndex, although markConversationUnread's resolver has an explicit INVALID_REF guard for it. If that guard regressed, firstUnread would fall back to lastObjIndex and silently mark the latest message unread while printing "from message M5". Add a sibling test with a message whose objIndex is undefined (as thread mark-unread does for the equivalent comment guard), asserting the INVALID_REF error and that markUnread was not called.

Share Feedback • Review Logs • Trace

The inverse of `tdc conversation mark-read`, on the same read-state
runner, with the options of `tdc thread mark-unread`: one or more refs
(or --stdin), --yes for a bulk run, --dry-run, --json rows, and
--from <message-ref> for a single conversation.

A conversation's unread marker is its first unread message, so --from
marks that message and everything after it unread. Without --from it
marks the latest message unread, as "Mark unread" on a conversation does
in the Comms app, rather than the whole history. The --json rows report
lastReadObjIndex, the last message still read, as the thread rows do.
@scottlovegrove
scottlovegrove force-pushed the scottl/conversation-mark-unread branch from cc8d0ef to ef60218 Compare December 4, 2026 14:49
@scottlovegrove scottlovegrove added the 👀 Show PR requires passing checks before merge and independent human review before or after merge. label Dec 4, 2026
@scottlovegrove
scottlovegrove requested review from a team and rmartins90 and removed request for a team December 4, 2026 15:03
@scottlovegrove
scottlovegrove merged commit c9c02e8 into main Dec 4, 2026
5 checks passed
@scottlovegrove
scottlovegrove deleted the scottl/conversation-mark-unread branch December 4, 2026 15:04
doist-release-bot Bot added a commit that referenced this pull request Dec 4, 2026
## [6.1.0](v6.0.1...v6.1.0) (2026-12-04)

### Features

* **conversation:** add tdc conversation mark-read ([#147](#147)) ([bda7dcf](bda7dcf))
* **conversation:** add tdc conversation mark-unread ([#148](#148)) ([c9c02e8](c9c02e8))

### Bug Fixes

* mark the thread or conversation read when replying ([#144](#144)) ([e061f51](e061f51))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR requires passing checks before merge and independent human review before or after merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants