Skip to content

Commit 2d36421

Browse files
authored
Merge pull request #290 from plotday/today-note-todayitem-field
Add Note.todayItem for reading Today-item pin context
2 parents 3cec53a + c3d9d3e commit 2d36421

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@plotday/twister": minor
3+
---
4+
5+
Added: `Note.todayItem` — when a message is sent while a Today item is
6+
pinned as context, the note carries `{ id }` pointing at that item. Twists
7+
can read `note.todayItem` in a note handler to know which Today item a
8+
message refers to. Read-only (not settable via `NewNote`).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { describe, expectTypeOf, it } from "vitest";
2+
import type { Note, NewNote } from "./plot";
3+
4+
describe("Note.todayItem", () => {
5+
it("is a required { id } | null field on Note", () => {
6+
expectTypeOf<Note["todayItem"]>().toEqualTypeOf<{ id: Note["id"] } | null>();
7+
});
8+
it("is NOT settable on NewNote", () => {
9+
expectTypeOf<NewNote>().not.toHaveProperty("todayItem");
10+
});
11+
});

‎twister/src/plot.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,15 @@ export type Note = ThreadCommon & {
732732
actions: Array<Action> | null;
733733
/** The note this is a reply to, or null if not a reply */
734734
reNote: { id: Uuid } | null;
735+
/**
736+
* The Today-item context this note was composed against, via the Today
737+
* thread's pin affordance (pin an item to discuss it), or null. Mutually
738+
* exclusive with `reNote` and a forward snapshot — a note is at most one
739+
* of a reply, a forward, or a Today-item reference. Read-only from a
740+
* twist's perspective: only the Plot app sets it, when the user pins a
741+
* Today item and sends a message in the Today thread.
742+
*/
743+
todayItem: { id: Uuid } | null;
735744
/**
736745
* Contacts who can see this note, or null if the note inherits thread visibility.
737746
* When set (even to []), the note is private to the listed contacts plus the creator.
@@ -795,7 +804,7 @@ export type Note = ThreadCommon & {
795804
export type NewNote = Partial<
796805
Omit<
797806
Note,
798-
"author" | "thread" | "tags" | "reactions" | "mentions" | "accessContacts" | "recipients" | "id" | "key" | "reNote" | "tagActors"
807+
"author" | "thread" | "tags" | "reactions" | "mentions" | "accessContacts" | "recipients" | "id" | "key" | "reNote" | "todayItem" | "tagActors"
799808
>
800809
> &
801810
({ id: Uuid } | { key: string } | {}) & {

0 commit comments

Comments
 (0)