terminalhire 0.15.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4597,29 +4597,14 @@ async function gateDisclosure(ensureDisclosure, input, output) {
4597
4597
  }
4598
4598
  return true;
4599
4599
  }
4600
- async function runInbox(opts = {}) {
4600
+ async function buildInboxItems(deps = {}) {
4601
4601
  const {
4602
- output = process.stdout,
4603
- input = process.stdin,
4604
4602
  client = createChatClient(),
4605
4603
  listConnections = defaultListConnections,
4606
- listInvites = defaultListPendingInvites,
4607
- readCursors = readReadCursors,
4608
- ensureDisclosure = ensureChatDisclosure
4609
- } = opts;
4610
- if (!await gateDisclosure(ensureDisclosure, input, output)) {
4611
- return { ok: false, reason: "not-acknowledged" };
4612
- }
4604
+ readCursors = readReadCursors
4605
+ } = deps;
4613
4606
  const listed = await listConnections();
4614
- if (listed.status !== "ok") {
4615
- return { ok: false, reason: writeProblem(output, listed, "") };
4616
- }
4617
- let invites = [];
4618
- try {
4619
- const inv = await listInvites();
4620
- if (inv && inv.status === "ok") invites = inv.invites;
4621
- } catch {
4622
- }
4607
+ if (listed.status !== "ok") return listed;
4623
4608
  const cursors = readCursors();
4624
4609
  const items = [];
4625
4610
  for (const conn of listed.connections) {
@@ -4639,11 +4624,39 @@ async function runInbox(opts = {}) {
4639
4624
  presence: REACHABLE_DISPLAY,
4640
4625
  unread,
4641
4626
  lastStamp: last ? formatStamp(last.createdAt) : "",
4627
+ // Raw ISO of the newest message — the TUI's `r` key marks the thread read at
4628
+ // this exact watermark (postReadCursor). The formatted lastStamp is display-only.
4629
+ lastStampIso: last ? last.createdAt : null,
4642
4630
  preview: last ? last.plaintext : ""
4643
4631
  });
4644
4632
  }
4645
- output.write(renderInbox(items, invites));
4646
- return { ok: true, count: items.length, invites: invites.length };
4633
+ return { status: "ok", items };
4634
+ }
4635
+ async function runInbox(opts = {}) {
4636
+ const {
4637
+ output = process.stdout,
4638
+ input = process.stdin,
4639
+ client = createChatClient(),
4640
+ listConnections = defaultListConnections,
4641
+ listInvites = defaultListPendingInvites,
4642
+ readCursors = readReadCursors,
4643
+ ensureDisclosure = ensureChatDisclosure
4644
+ } = opts;
4645
+ if (!await gateDisclosure(ensureDisclosure, input, output)) {
4646
+ return { ok: false, reason: "not-acknowledged" };
4647
+ }
4648
+ const built = await buildInboxItems({ client, listConnections, readCursors });
4649
+ if (built.status !== "ok") {
4650
+ return { ok: false, reason: writeProblem(output, built, "") };
4651
+ }
4652
+ let invites = [];
4653
+ try {
4654
+ const inv = await listInvites();
4655
+ if (inv && inv.status === "ok") invites = inv.invites;
4656
+ } catch {
4657
+ }
4658
+ output.write(renderInbox(built.items, invites));
4659
+ return { ok: true, count: built.items.length, invites: invites.length };
4647
4660
  }
4648
4661
  async function runReadThread(opts = {}) {
4649
4662
  const {
@@ -4781,6 +4794,7 @@ var init_jpi_chat_read = __esm({
4781
4794
  });
4782
4795
  init_jpi_chat_read();
4783
4796
  export {
4797
+ buildInboxItems,
4784
4798
  formatClock,
4785
4799
  formatStamp,
4786
4800
  postReadCursor,