@mrciphersmith/roomyx 0.7.1 → 0.7.2

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.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,36 @@ patch and never a minor. The rule, the reason, and an audit of the four of seven
13
13
  releases that followed it are in
14
14
  [`docs/roomyx/versioning.md`](docs/roomyx/versioning.md) and decision D-13.
15
15
 
16
+ ## [0.7.2] — 2026-09-10
17
+
18
+ A patch. Found by reading a real room log: the reply structure the log schema
19
+ exists to record was, in the pane that displays it, a number.
20
+
21
+ ### Fixed
22
+
23
+ - **A reply names the participant it answers, instead of a sequence number.**
24
+ The tag read `answer re #4` — a number the client never resolved to a speaker,
25
+ neither in the pane nor in the file `w` writes out. In the log this was
26
+ measured against, four of nine messages reply and two of them answer the same
27
+ message, so two rows rendered as identical, unresolvable tags. The pointer now
28
+ reads `answer -> Inés "..."`, carrying a short clipped quote of the parent.
29
+ - **The kind and the reply pointer no longer vanish when a header is
30
+ collapsed.** Both were drawn inside the header, which is suppressed for
31
+ consecutive turns by one speaker, so a second turn looked exactly like a plain
32
+ continuation. Because the run was computed over the visible list, filtering to
33
+ one participant could also *hide* a tag that was there unfiltered.
34
+ - **`/` finds a row by the text its pointer shows.** The tag is on screen and
35
+ the search haystack did not include it.
36
+
37
+ ### Notes
38
+
39
+ - Rendering only: no MCP tool surface, CLI flag or room-log format changed.
40
+ - The pointer uses an ASCII `->` and `...` rather than `→` and `…`, which are
41
+ East-Asian-ambiguous: their width depends on the reader's terminal, and a
42
+ wrong guess shifts the whole wrapped row.
43
+ - The tripwire in `test/client/wrap-defect.test.ts` is untouched and still
44
+ failing as designed.
45
+
16
46
  ## [0.7.1] — 2026-09-10
17
47
 
18
48
  A patch. Found while writing setup prompts for an operator: following the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/roomyx",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "MCP server + terminal UI for startup-room: live room status, chat, per-agent modal, an installable room registry, and skill-sync.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,5 +1,7 @@
1
1
  import { BoxRenderable, TextRenderable } from "@opentui/core";
2
2
  import type { RenderContext } from "@opentui/core";
3
+ import { messageTag } from "../transcript";
4
+ import type { ReplyTarget } from "../transcript";
3
5
  import type { MessageEnvelope } from "../../log/types";
4
6
 
5
7
  /**
@@ -23,6 +25,14 @@ import type { MessageEnvelope } from "../../log/types";
23
25
  * The tag stays ASCII on purpose: `↩` and `→` are East-Asian-ambiguous, so
24
26
  * their width depends on the reader's terminal, and a wrong guess shifts the
25
27
  * whole wrapped row.
28
+ *
29
+ * A third defect lived in this file and is kept written down for the same
30
+ * reason: the tag was added *inside* the header, and the header is suppressed
31
+ * for consecutive turns by one speaker — so the second turn lost its kind and
32
+ * its reply pointer, and two materially different messages rendered
33
+ * identically. Whether a header is drawn is a question about the speaker;
34
+ * whether a tag is drawn is a question about the message, and they are not the
35
+ * same question. See D-17.
26
36
  */
27
37
  export const SPEAKER_FG = "#ffffff";
28
38
  export const TAG_FG = "#8a8a8a";
@@ -36,12 +46,8 @@ export interface MessageRowOptions {
36
46
  showHeader: boolean;
37
47
  /** False for the first row, which needs no separating blank line above it. */
38
48
  separate: boolean;
39
- }
40
-
41
- function tagFor(message: MessageEnvelope): string {
42
- return [message.kind, message.in_reply_to === undefined ? null : `re #${message.in_reply_to}`]
43
- .filter((part): part is string => Boolean(part))
44
- .join(" ");
49
+ /** The turn this one answers, already resolved to a speaker by the caller. */
50
+ replyTo?: ReplyTarget;
45
51
  }
46
52
 
47
53
  export function createMessageRow(
@@ -55,12 +61,17 @@ export function createMessageRow(
55
61
  marginTop: options.separate ? 1 : 0,
56
62
  });
57
63
 
64
+ const tag = messageTag(message, options.replyTo);
65
+
58
66
  if (options.showHeader) {
59
67
  const header = new BoxRenderable(ctx, { flexDirection: "row", height: 1 });
60
68
  header.add(new TextRenderable(ctx, { content: fromName, fg: SPEAKER_FG, attributes: 1, height: 1 }));
61
- const tag = tagFor(message);
62
69
  if (tag) header.add(new TextRenderable(ctx, { content: ` ${tag}`, fg: TAG_FG, height: 1 }));
63
70
  row.add(header);
71
+ } else if (tag) {
72
+ // Its own indented line, because there is no header to sit in. The kind and
73
+ // the pointer must not be collapsible with the speaker's name.
74
+ row.add(new TextRenderable(ctx, { content: tag, fg: TAG_FG, height: 1, marginLeft: 2 }));
64
75
  }
65
76
 
66
77
  row.add(
@@ -37,6 +37,12 @@ export class ChatView {
37
37
  private readonly scroll: ScrollBoxRenderable;
38
38
  private readonly ctx: RenderContext;
39
39
  private rosterById = new Map<string, RosterEntry>();
40
+ /**
41
+ * Every message seen so far, by `seq`, so a reply pointer can name its
42
+ * parent. Kept here rather than in `Transcript` because the roster — the
43
+ * thing that turns an id into a name — is here too.
44
+ */
45
+ private messagesBySeq = new Map<number, MessageEnvelope>();
40
46
  private rows: Renderable[] = [];
41
47
  private readonly rosterVisible: boolean;
42
48
 
@@ -112,11 +118,23 @@ export class ChatView {
112
118
 
113
119
  appendMessages(messages: MessageEnvelope[]): void {
114
120
  for (const message of messages) {
121
+ // Resolved before this message is recorded, so a pointer can only ever
122
+ // name an *earlier* turn — the log is append-only and the parent is
123
+ // always already here. That is what lets a tag be known when the row is
124
+ // built and keeps rendering incremental: no drawn row is ever amended.
125
+ const parent =
126
+ message.in_reply_to === undefined ? undefined : this.messagesBySeq.get(message.in_reply_to);
127
+ const replyTo =
128
+ parent === undefined
129
+ ? undefined
130
+ : { name: this.rosterById.get(parent.from)?.name ?? parent.from, body: parent.body };
115
131
  this.appendEntry({
116
132
  kind: "message",
117
133
  message,
118
134
  fromName: this.rosterById.get(message.from)?.name ?? message.from,
135
+ ...(replyTo === undefined ? {} : { replyTo }),
119
136
  });
137
+ this.messagesBySeq.set(message.seq, message);
120
138
  }
121
139
  }
122
140
 
@@ -206,6 +224,7 @@ export class ChatView {
206
224
  // changed.
207
225
  showHeader: this.transcript.startsRun(index),
208
226
  separate,
227
+ ...(entry.replyTo === undefined ? {} : { replyTo: entry.replyTo }),
209
228
  });
210
229
 
211
230
  this.rows.push(row);
@@ -25,6 +25,13 @@ export interface MessageEntry {
25
25
  message: MessageEnvelope;
26
26
  /** Resolved display name, so the model can be searched by what is on screen. */
27
27
  fromName: string;
28
+ /**
29
+ * The turn this one answers, resolved to a speaker by whoever built the
30
+ * entry. Absent when the message answers nothing, or answers a `seq` this
31
+ * log does not contain — and absent means nothing is drawn, which is the
32
+ * point: the number it replaced named nobody (D-17).
33
+ */
34
+ replyTo?: ReplyTarget;
28
35
  }
29
36
 
30
37
  export type Entry = MessageEntry | SystemEntry;
@@ -75,7 +82,7 @@ export class Transcript {
75
82
  const haystack =
76
83
  entry.kind === "system"
77
84
  ? entry.text
78
- : `${entry.fromName} ${entry.message.kind ?? ""} ${entry.message.body}`;
85
+ : `${entry.fromName} ${messageTag(entry.message, entry.replyTo)} ${entry.message.body}`;
79
86
  return haystack.toLowerCase().includes(needle) ? index : -1;
80
87
  })
81
88
  .filter((index) => index >= 0);
@@ -114,11 +121,57 @@ export class Transcript {
114
121
  return this.visible()
115
122
  .map((entry) => {
116
123
  if (entry.kind === "system") return `— ${entry.text} —`;
117
- const tag = [entry.message.kind, entry.message.in_reply_to === undefined ? null : `re #${entry.message.in_reply_to}`]
118
- .filter((part): part is string => Boolean(part))
119
- .join(" ");
124
+ const tag = messageTag(entry.message, entry.replyTo);
120
125
  return `${entry.fromName}${tag ? ` ${tag}` : ""}\n ${entry.message.body}`;
121
126
  })
122
127
  .join("\n\n");
123
128
  }
124
129
  }
130
+
131
+ /**
132
+ * How much of the parent's body the pointer quotes, in code units.
133
+ *
134
+ * A budget rather than a proportion of the pane: the tag sits on one
135
+ * `height: 1` line beside a name, and anything that has to be measured against
136
+ * a live width would make the tag's text depend on the terminal it is drawn in.
137
+ * Code units, not display cells — the same deferral `clip.ts` records for the
138
+ * same reason.
139
+ */
140
+ const QUOTE_CELLS = 24;
141
+
142
+ export interface ReplyTarget {
143
+ /** The parent's resolved display name. Never a sequence number: a number names nobody. */
144
+ name: string;
145
+ /** The parent's body, for the short quote. */
146
+ body: string;
147
+ }
148
+
149
+ /**
150
+ * Cut to size in ASCII.
151
+ *
152
+ * `clip()` — the client's other cutter — marks a cut with `…`, and this line
153
+ * must not: U+2026 is East-Asian-ambiguous, so its width depends on the
154
+ * reader's terminal, and the tag is laid out against the same pane the body
155
+ * wraps in. A quote is context, not content; it does not get to move where a
156
+ * sentence breaks.
157
+ */
158
+ function quote(body: string): string {
159
+ // Whitespace is flattened first: a parent's newline would otherwise put a
160
+ // second line under a tag that is `height: 1`.
161
+ const flat = body.replace(/\s+/g, " ").trim();
162
+ if (flat.length <= QUOTE_CELLS) return flat;
163
+ return `${flat.slice(0, QUOTE_CELLS - 3).trimEnd()}...`;
164
+ }
165
+
166
+ /**
167
+ * The one place the kind and reply tag is spelled.
168
+ *
169
+ * It used to be assembled twice — in `message-row.ts` for the pane, and inline
170
+ * in `toText()` for the export — so the two could disagree about what a message
171
+ * said, and neither was visible to `matches()`. The tag is drawn on screen,
172
+ * which is the whole test of whether a search has to find it.
173
+ */
174
+ export function messageTag(message: MessageEnvelope, replyTo?: ReplyTarget): string {
175
+ const pointer = replyTo === undefined ? "" : `-> ${replyTo.name} "${quote(replyTo.body)}"`;
176
+ return [message.kind, pointer].filter((part): part is string => Boolean(part)).join(" ");
177
+ }