Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(show): put the mark transcript into plain language (#1026)

Call White458831eb0095
diff --git a/core/show_session_events.py b/core/show_session_events.py
index a63110484..16e7e0fce 100644
--- a/core/show_session_events.py
+++ b/core/show_session_events.py
@@ -85,6 +85,36 @@ SHOW_EVENT_ERROR_I18N_KEYS = {
}
_ACTIVE_SHOW_DISPATCH_ATTEMPTS: set[str] = set()
_ACTIVE_SHOW_DISPATCH_ATTEMPTS_LOCK = threading.Lock()
+# Assistant marks are projected into the chat as a message the *user* reads, so
+# every member needs its own plain-language label. Keeping the mapping next to
+# the event set (and asserting they enumerate each other in tests) means a fourth
+# mark event fails a test instead of leaking a raw i18n key into a conversation.
+ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS = {
+ "assistant.mark.created": "show.mark.created",
+ "assistant.mark.updated": "show.mark.updated",
+ "assistant.mark.resolved": "show.mark.resolved",
+}
+# The *only* fields the user-facing locator may come from, best first. Both hold
+# copy the user can see on the page: ``vibe show mark --anchor-text`` writes
+# ``text``, while ``vibe show reply`` copies the annotation's anchor verbatim and
+# a text-range annotation carries its selected copy as ``textQuote``.
+#
+# Deliberately excluded is every locator the mark itself carries. ``vibe show mark``
+# documents ``target`` as "Target mark id or selector" and ``scope`` as an
+# organizational key, so both are machine text by contract -- and no rule can tell a
+# bare type selector like ``button`` or a scope like ``hero`` from a page label of the
+# same shape. Rather than adjudicate that ambiguity with a predicate (a blacklist that
+# reads complete and never is), the transcript prints neither.
+ANCHOR_HUMAN_COPY_KEYS = ("textQuote", "text")
+# Longest locator the transcript header will carry before eliding; a header is one
+# line, and anchor copy can be a whole paragraph of the page.
+MARK_LOCATOR_MAX_LENGTH = 60
+# Everything a stored mark is made of. ``body`` is the agent's own words and the only
+# member the user-facing header may render; the rest are ids, timestamps, and the
+# machine-text locators above -- written for the runtime, not for a reader. The
+# transcript invariant is asserted over this enumeration, so a field added here has to
+# prove it stays out of chat rather than leaking on the next release.
+MARK_PAYLOAD_KEYS = ("id", "scope", "target", "body", "createdAt", "updatedAt", "replyTo")
class ShowSessionEventError(ValueError):
@@ -699,6 +729,9 @@ class ShowSessionEventStore:
event_id = _event_id(payload, {})
request_fingerprint = _event_request_fingerprint(event_type, payload)
created_at = _utc_now_iso()
+ # Resolved once per append, outside the transaction: transcript text is
+ # rendered for the user at write time, so it needs their display language.
+ lang = _configured_language()
with ExitStack() as cleanup:
with self.engine.begin() as conn:
@@ -750,7 +783,7 @@ class ShowSessionEventStore:
transcript_text = (
""
if event_type == "assistant.mark.resolved" and author is not None
- else _format_transcript_text(event_type, event_payload, anchor)
+ else _format_transcript_text(event_type, event_payload, anchor, lang=lang)
)
if records_author:
event_payload["author"] = _normalize_human_author(author)
@@ -1010,7 +1043,7 @@ def _prepare_mark_resolution(conn: Any, session_id: str, payload: dict[str, Any]
mark = {
key: active_mark[key]
- for key in ("id", "scope", "target", "body", "createdAt", "updatedAt", "replyTo")
+ for key in MARK_PAYLOAD_KEYS
if active_mark.get(key) is not None
}
return {
@@ -1369,29 +1402,83 @@ def _format_transcript_header(
return f"[{' '.join(parts)}]"
-def _format_transcript_text(event_type: str, payload: dict[str, Any], anchor: dict[str, Any]) -> str:
+def _condense_mark_locator(value: str) -> str:
+ collapsed = " ".join(value.split())
+ if len(collapsed) <= MARK_LOCATOR_MAX_LENGTH:
+ return collapsed
+ return collapsed[: MARK_LOCATOR_MAX_LENGTH - 1].rstrip() + "…"
+
+
+def _mark_locator(anchor: dict[str, Any]) -> str | None:
+ """Words the user can match against the page, or nothing at all.
+
+ Only anchor copy qualifies — see :data:`ANCHOR_HUMAN_COPY_KEYS` for why the
+ mark's ``target`` is not a fallback. Without it the header simply says what
+ happened and the agent's own message says the rest; a locator the user cannot
+ read is not a locator, just noise wearing the word "where".
+ """
+ for key in ANCHOR_HUMAN_COPY_KEYS:
+ anchor_copy = _text_or_none(anchor.get(key))
+ if anchor_copy:
+ return _condense_mark_locator(anchor_copy)
+ return None
+
+
+def _configured_language() -> str:
+ """Display language for user-visible transcript text.
+
+ The store has no controller to read config off, so it loads the persisted
+ config directly; a headless run with no config file (tests, a fresh CLI) falls
+ back to English, the documented default.
+ """
+ from config.v2_config import V2Config
+
+ try:
+ return str(getattr(V2Config.load(), "language", "en") or "en")
+ except (OSError, ValueError):
+ return "en"
+
+
+def _format_assistant_mark_text(
+ event_type: str,
+ payload: dict[str, Any],
+ anchor: dict[str, Any],
+ *,
+ lang: str,
+) -> str:
+ """Render an assistant mark as the chat message a user reads.
+
+ The agent's own words are the message; the header is a short line saying what
+ happened and, when it can be said in plain words, where.
+
+ The header is assembled from exactly two sources, and that is the invariant:
+ a closed label map keyed by event type, and anchor copy the user can see on
+ the page. No free-form field of the mark reaches the user -- not ``target``
+ (see :data:`ANCHOR_HUMAN_COPY_KEYS`), and not ``scope``, which namespaces the
+ synthetic mark id in :func:`stable_assistant_mark_id`, never appears anywhere
+ on the page, and so names nothing the reader could go and look at. ``body``,
+ the agent's own ``--message``, is the one payload field that is human words by
+ construction, and it is the message rather than the header.
+ """
+ header = i18n_t(ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS[event_type], lang)
+ locator = _mark_locator(anchor)
+ if locator:
+ header = i18n_t("show.mark.quoteSuffix", lang, header=header, quote=locator)
+ body = str(payload.get("body") or "").strip()
+ return f"{header}\n\n{body}" if body else header
+
+
+def _format_transcript_text(
+ event_type: str,
+ payload: dict[str, Any],
+ anchor: dict[str, Any],
+ *,
+ lang: str = "en",
+) -> str:
if event_type == "system.annotation.control":
return ""
- if event_type.startswith("assistant.mark."):
- action = event_type.split(".")[-1]
- header = _format_transcript_header(
- "agent-mark",
- scope=payload.get("scope"),
- action=action,
- default_action="created",
- )
- lines = [
- f"{header} {payload.get('target')}",
- "",
- str(payload.get("body") or "").strip(),
- ]
- selector = _text_or_none(anchor.get("selector"))
- if selector:
- lines.extend(["", f"Anchor: {selector}"])
- text = _text_or_none(anchor.get("text"))
- if text:
- lines.append(f"Text: {text}")
- return "\n".join(lines)
+ if event_type in ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS:
+ return _format_assistant_mark_text(event_type, payload, anchor, lang=lang)
if event_type == "human.intent.submitted":
text = _text_or_none(payload.get("text") or payload.get("comment") or payload.get("value"))
diff --git a/tests/test_show_pages.py b/tests/test_show_pages.py
index 0b3267ab9..f51a23c58 100644
--- a/tests/test_show_pages.py
+++ b/tests/test_show_pages.py
@@ -2206,13 +2206,92 @@ def test_show_mark_cli_records_event_and_message(monkeypatch, tmp_path, capsys):
assert payload["ok"] is True
assert payload["event"]["type"] == "assistant.mark.created"
assert payload["event"]["message_id"]
- assert payload["event"]["transcript_text"].startswith("[agent-mark] mark-default-summary")
+ # No anchor text and a synthetic target: the header stands alone rather than
+ # falling back to printing the handle at the user.
+ assert payload["event"]["transcript_text"] == "Page note\n\nReview this summary."
with engine.connect() as conn:
assert conn.execute(select(show_session_events.c.id)).scalar_one() == payload["event"]["id"]
assert "Review this summary." in conn.execute(select(messages.c.content_text)).scalar_one()
+ ("flags", "expected_anchor"),
+ [
+ (["--anchor-text", "Checkout"], {"text": "Checkout"}),
+ (["--anchor-selector", "#cta"], {"selector": "#cta"}),
+ (
+ ["--anchor-selector", "#cta", "--anchor-text", "Checkout"],
+ {"selector": "#cta", "text": "Checkout"},
+ ),
+ ],
+ ids=["text-only", "selector-only", "both"],
+)
+def test_show_mark_keeps_anchor_text_without_a_selector(monkeypatch, tmp_path, capsys, flags, expected_anchor):
+ """``--anchor-text`` alone is a valid invocation and must survive.
+
+ The parser advertises the two anchor flags independently, but the payload used
+ to build an anchor only when a selector was present, so a standalone
+ ``--anchor-text`` was silently discarded. That was invisible while the
+ transcript fell back to printing ``target``; now that the locator comes only
+ from anchor copy, dropping it loses the one human-readable locator the agent
+ supplied.
+ """
+ from sqlalchemy import select
+
+ from storage import messages_service
+ from storage.db import create_sqlite_engine
+ from storage.importer import ensure_sqlite_state
+ from storage.models import agent_sessions, show_session_events
+ from storage.settings_service import upsert_scope
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ paths.ensure_data_dirs()
+ _save_config()
+ ensure_sqlite_state()
+
+ engine = create_sqlite_engine()
+ now = messages_service._utc_now_iso()
+ with engine.begin() as conn:
+ scope_id = upsert_scope(conn, platform="avibe", scope_type="project", native_id="proj_show", now=now)
+ conn.execute(
+ agent_sessions.insert().values(
+ id="ses123",
+ scope_id=scope_id,
+ agent_backend="codex",
+ agent_variant="default",
+ session_anchor="anchor_ses123",
+ native_session_id="",
+ status="active",
+ metadata_json="{}",
+ created_at=now,
+ updated_at=now,
+ last_active_at=now,
+ )
+ )
+
+ args = cli.build_parser().parse_args(
+ ["show", "mark", "--session-id", "ses123", "--target", "cta", "--body", "Aligned it.", "--json", *flags]
+ )
+ assert cli.cmd_show(args) == 0
+
+ payload = json.loads(capsys.readouterr().out)
+ assert payload["ok"] is True
+
+ with engine.connect() as conn:
+ anchor = json.loads(conn.execute(select(show_session_events.c.anchor_json)).scalar_one())
+ assert anchor == expected_anchor
+
+ # The user-facing echo locates the mark whenever anchor copy was supplied, and
+ # never leaks the selector that may sit beside it.
+ transcript = payload["event"]["transcript_text"]
+ if "text" in expected_anchor:
+ assert transcript == "Page note · “Checkout”\n\nAligned it."
+ else:
+ assert transcript == "Page note\n\nAligned it."
+ assert "#cta" not in transcript
+
+
def test_show_mark_defaults_to_caller_session(monkeypatch, tmp_path, capsys):
from sqlalchemy import select
@@ -2296,7 +2375,7 @@ def test_show_mark_cli_posts_to_live_ui_when_running(monkeypatch, tmp_path, caps
"scope": "default",
"anchor": {},
"payload": {},
- "transcript_text": "[agent-mark] mark-default-summary\n\nReview this summary.",
+ "transcript_text": "Page note\n\nReview this summary.",
"message_id": "msg_live",
"message": {"id": "msg_live"},
"created_at": "now",
@@ -2380,6 +2459,10 @@ def test_show_reply_copies_annotation_anchor_and_replaces_prior_reply(monkeypatc
assert first["mark_id"] == second["mark_id"]
assert first["event"]["anchor"] == annotation["anchor"]
assert first["event"]["payload"]["target"] == "#revenue-card"
+ # A reply copies the annotation's anchor, so the chat message can quote the copy
+ # the user highlighted; the reply target is the selector and stays out of sight.
+ assert first["event"]["transcript_text"] == "Page note · “Revenue”\n\nFirst answer."
+ assert "#revenue-card" not in first["event"]["transcript_text"]
assert first["event"]["payload"]["replyTo"] == annotation["id"]
assert second["replaced"] is True
assert "vibe show marks" in second["replacement_notice"]
diff --git a/tests/test_show_session_events.py b/tests/test_show_session_events.py
index bd61779ac..819edff16 100644
--- a/tests/test_show_session_events.py
+++ b/tests/test_show_session_events.py
@@ -11,11 +11,16 @@ import pytest
from sqlalchemy import select
from core.show_session_events import (
+ ANCHOR_HUMAN_COPY_KEYS,
+ ASSISTANT_MARK_EVENT_TYPES,
+ ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS,
DISPATCH_ACCEPTED,
DISPATCH_ARCHIVED,
DISPATCH_FAILED,
DISPATCH_IN_FLIGHT,
DISPATCH_NONE,
+ MARK_LOCATOR_MAX_LENGTH,
+ MARK_PAYLOAD_KEYS,
ShowDispatchSettlement,
ShowDispatchStatus,
ShowSessionEventError,
@@ -123,8 +128,11 @@ def test_show_event_store_records_assistant_mark_and_transcript_message(isolated
assert event["scope"] == "default"
assert event["message_id"]
assert event["message"]["id"] == event["message_id"]
- assert "[agent-mark] mark-default-summary" in event["transcript_text"]
- assert "Anchor: [mark-default='summary']" in event["transcript_text"]
+ # The user reads this one, so it says what happened and quotes copy they can
+ # see on the page — never the synthetic target or the selector behind it.
+ assert event["transcript_text"] == 'Page note · “Quarterly summary”\n\nReview this summary again.'
+ assert "mark-default-summary" not in event["transcript_text"]
+ assert "[mark-default='summary']" not in event["transcript_text"]
with engine.connect() as conn:
event_row = conn.execute(select(show_session_events)).mappings().one()
@@ -827,20 +835,26 @@ def test_show_event_store_records_assistant_page_update(isolated_state):
@pytest.mark.parametrize(
("event_type", "payload", "expected_header"),
[
+ # The three mark rows pin the action wording. They also carry a `scope` and
+ # a `target` that no header renders, so the rows below double as the
+ # contrast this table exists to show: the very same `scope: "review"` that
+ # is invisible to the user in a mark stays visible to the Agent in the
+ # `[show-intent ...]` / `[show-annotation ...]` rows further down, because
+ # only there is it something the reader can act on.
(
"assistant.mark.created",
{"scope": "default", "target": "summary", "body": "Created."},
- "[agent-mark] summary",
+ "Page note",
),
(
"assistant.mark.resolved",
{"scope": "default", "target": "summary", "body": "Resolved."},
- "[agent-mark resolved] summary",
+ "Page note (resolved)",
),
(
"assistant.mark.updated",
{"scope": "review", "target": "summary", "body": "Updated."},
- "[agent-mark updated scope=review] summary",
+ "Page note (updated)",
),
(
"human.intent.submitted",
@@ -880,6 +894,232 @@ def test_show_event_transcript_headers_only_render_deviations(event_type, payloa
assert transcript.splitlines()[0] == expected_header
+ "target",
+ [
+ "#root > div.grid > section:nth-child(3) .cta-button", # compound selector
+ "mark-default-summary", # synthetic mark handle
+ "mark_9f2a7c1d", # synthetic mark handle, underscore form
+ "[data-testid='cta']", # attribute selector
+ "button", # bare type selector -- indistinguishable from a page label
+ "summary", # ditto, and the documented example in `vibe show mark --help`
+ "Get started", # reads like copy, but the field's contract is machine text
+ None, # nothing to say
+ ],
+)
+def test_assistant_mark_transcript_never_shows_the_mark_target(target):
+ """The hard invariant, enforced structurally: ``target`` is never printed.
+
+ Every value here is what an agent may legitimately pass to ``vibe show mark``.
+ ``button`` and ``summary`` are the reason this is a blanket rule rather than a
+ predicate: as strings they are both valid bare type selectors and plausible page
+ labels, so no test on the text can separate the safe case from the unsafe one.
+ The last case shows the cost we accepted -- copy in the wrong field is dropped
+ too, because the field cannot promise it is copy.
+ """
+ transcript = _format_transcript_text("assistant.mark.created", {"target": target, "body": "Aligned it."}, {})
+
+ assert transcript == "Page note\n\nAligned it."
+
+
+ "scope",
+ [
+ "#hero", # a selector used as a filing key
+ "mark_9f2a7c1d", # a synthetic id used as a filing key
+ "summary", # indistinguishable from a page label, exactly like `target`
+ "review", # reads perfectly well -- and still names nothing on the page
+ ],
+)
+def test_assistant_mark_transcript_never_shows_the_mark_scope(scope):
+ """``scope`` is dropped for a reason ``target`` did not even need.
+
+ It is unvalidated free text that namespaces the synthetic mark id, so it is
+ machine text by contract. But it fails a second test too: it is rendered
+ nowhere on the page, so even the well-behaved ``review`` names nothing the
+ reader could go and look at. A locator has to point at something visible.
+
+ The same value stays visible in the *agent*-facing direction -- see the
+ ``[show-intent scope=review]`` rows in the shared header table -- because
+ there the reader can act on it.
+ """
+ payload = {"scope": scope, "target": "cta", "body": "Aligned it."}
+
+ transcript = _format_transcript_text("assistant.mark.created", payload, {})
+
+ assert transcript == "Page note\n\nAligned it."
+
+
+def test_no_machine_field_of_a_mark_ever_reaches_the_chat():
+ """Closes the class instead of patching one member of it.
+
+ Two rounds of review found the same leak in two different fields. Rather than
+ wait for a third, this drives every field a stored mark is made of, each
+ holding text a user must never be shown, and asserts the chat message is the
+ header plus the agent's own words. The equality check makes the enumeration
+ binding: adding a key to ``MARK_PAYLOAD_KEYS`` fails here until someone
+ classifies it as the agent's words or as machine text.
+ """
+ machine_text = {
+ "id": "mark_9f2a7c1d",
+ "scope": "#hero",
+ "target": "#root > div.grid > section:nth-child(3) .cta-button",
+ "createdAt": "2026-07-26T10:00:00+00:00",
+ "updatedAt": "2026-07-26T10:05:00+00:00",
+ "replyTo": "mark_0badc0de",
+ }
+ assert set(machine_text) | {"body"} == set(MARK_PAYLOAD_KEYS)
+
+ transcript = _format_transcript_text(
+ "assistant.mark.created", {**machine_text, "body": "Aligned it."}, {}
+ )
+
+ assert transcript == "Page note\n\nAligned it."
+ for key, value in machine_text.items():
+ assert value not in transcript, f"{key} leaked into the chat"
+
+
+def test_assistant_mark_transcript_quotes_page_copy_the_user_can_see():
+ """The anchor is the only human source, so it is the only thing that locates."""
+ transcript = _format_transcript_text(
+ "assistant.mark.created",
+ {"target": "cta", "body": "Aligned it."},
+ {"selector": "#root .cta-button", "text": "Get started"},
+ )
+
+ assert transcript == "Page note · “Get started”\n\nAligned it."
+ assert "#root .cta-button" not in transcript
+
+
+def test_assistant_mark_transcript_renders_in_the_configured_language():
+ transcript = _format_transcript_text(
+ "assistant.mark.updated",
+ {"target": "cta", "body": "改了按钮的对齐方式,和设计稿一致了"},
+ {"text": "开始使用"},
+ lang="zh",
+ )
+
+ assert transcript == "页面批注(已更新) ·「开始使用」\n\n改了按钮的对齐方式,和设计稿一致了"
+
+
+def test_assistant_mark_transcript_keeps_the_whole_body():
+ body = "Detail. " * 200
+ transcript = _format_transcript_text(
+ "assistant.mark.created",
+ {"target": "cta", "body": body},
+ {"text": "Get started"},
+ )
+
+ assert transcript.endswith(body.strip())
+
+
+def test_assistant_mark_transcript_quotes_a_text_range_anchor():
+ """`vibe show reply` copies the annotation anchor, which carries ``textQuote``."""
+ transcript = _format_transcript_text(
+ "assistant.mark.created",
+ {"target": "#revenue-card", "body": "Q3 restated the figure."},
+ {"kind": "text-range", "selector": "#revenue-card", "textQuote": "Revenue"},
+ )
+
+ assert transcript == "Page note · “Revenue”\n\nQ3 restated the figure."
+ assert "#revenue-card" not in transcript
+
+
[email protected]("copy_key", ANCHOR_HUMAN_COPY_KEYS)
+def test_both_transcript_directions_read_the_same_anchor_copy_fields(copy_key):
+ """The user-facing and agent-facing formatters must agree on where copy lives.
+
+ Adding a third anchor copy field to one side and not the other silently drops
+ the user's own words from whichever transcript forgot it, so pin both here.
+ """
+ mark = _format_transcript_text(
+ "assistant.mark.created",
+ {"target": "#revenue-card", "body": "Answered."},
+ {"selector": "#revenue-card", copy_key: "Revenue"},
+ )
+ annotation = _format_transcript_text(
+ "human.annotation.created",
+ {"comment": "Why?"},
+ {"selector": "#revenue-card", copy_key: "Revenue"},
+ )
+
+ assert mark == "Page note · “Revenue”\n\nAnswered."
+ assert "Quote: Revenue" in annotation
+
+
[email protected]("anchor", [{}, {"text": ""}, {"selector": "#cta"}], ids=["absent", "blank", "selector-only"])
+def test_assistant_mark_without_page_copy_is_just_the_agents_words(anchor):
+ """No human locator available: say what happened, then get out of the way."""
+ transcript = _format_transcript_text("assistant.mark.created", {"target": "cta", "body": "Aligned it."}, anchor)
+
+ assert transcript == "Page note\n\nAligned it."
+
+
[email protected]("copy_key", ANCHOR_HUMAN_COPY_KEYS)
+def test_assistant_mark_condenses_every_locator_source(copy_key):
+ """Whichever copy field fills the locator, the header stays one bounded line."""
+ transcript = _format_transcript_text(
+ "assistant.mark.created",
+ {"target": "cta", "body": "Aligned it."},
+ {copy_key: "Get\n started " + "x" * MARK_LOCATOR_MAX_LENGTH},
+ )
+ header = transcript.splitlines()[0]
+
+ assert header.startswith("Page note · “Get started x")
+ assert header.endswith("…”")
+ assert len(transcript.splitlines()) == 3 # header, blank, body
+
+
+def test_every_assistant_mark_event_has_a_plain_language_label():
+ """Adding a fourth mark event must fail here, not leak a raw key into chat."""
+ from vibe.i18n import get_supported_languages, t as i18n_t
+
+ assert set(ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS) == ASSISTANT_MARK_EVENT_TYPES
+ for lang in get_supported_languages():
+ for key in ASSISTANT_MARK_TRANSCRIPT_I18N_KEYS.values():
+ assert i18n_t(key, lang) != key
+
+
+def test_appended_mark_speaks_the_users_configured_language(isolated_state):
+ """The store has no controller, so prove it still reaches the saved language."""
+ from config.v2_config import (
+ AgentsConfig,
+ PlatformsConfig,
+ RuntimeConfig,
+ SlackConfig,
+ UiConfig,
+ V2Config,
+ )
+
+ V2Config(
+ mode="self_host",
+ version="v2",
+ platform="slack",
+ platforms=PlatformsConfig(enabled=["slack"], primary="slack"),
+ slack=SlackConfig(bot_token=""),
+ runtime=RuntimeConfig(default_cwd="."),
+ agents=AgentsConfig(),
+ ui=UiConfig(),
+ language="zh",
+ ).save()
+
+ _seed_session()
+ store = ShowSessionEventStore()
+ try:
+ event = store.append(
+ "ses_mark",
+ {
+ "type": "assistant.mark.created",
+ "mark": {"target": "#hero > .cta", "body": "按钮对齐改好了"},
+ "anchor": {"text": "开始使用"},
+ },
+ )
+ finally:
+ store.close()
+
+ assert event["transcript_text"] == "页面批注 ·「开始使用」\n\n按钮对齐改好了"
+
+
def test_show_event_store_rejects_unknown_session(isolated_state):
store = ShowSessionEventStore()
try:
diff --git a/vibe/cli.py b/vibe/cli.py
index 837e9719d..51df127b6 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -10939,10 +10939,17 @@ def cmd_show_mark(args):
"body": body,
},
}
- if args.anchor_selector:
- payload["anchor"] = {"selector": args.anchor_selector}
- if args.anchor_text:
- payload["anchor"]["text"] = args.anchor_text
+ # Either flag alone is a valid invocation -- the parser advertises them
+ # independently -- and `--anchor-text` is the one the chat transcript reads
+ # to tell the user where a mark landed, so nesting it under the selector
+ # dropped exactly the copy that locates the mark for a human.
+ anchor = {
+ key: value
+ for key, value in (("selector", args.anchor_selector), ("text", args.anchor_text))
+ if value
+ }
+ if anchor:
+ payload["anchor"] = anchor
event = _record_show_mark_event(session_id, payload, event_store)
result = _show_page_result(
page,
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index ef2f38704..4455965fe 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -17,6 +17,12 @@
"acceptanceUnknown": "The Show event may still be processing. It was not replayed locally.",
"dispatchFailed": "The Show event was recorded, but its agent turn could not be delivered.",
"idConflict": "This Show event ID is already bound to different event contents."
+ },
+ "mark": {
+ "created": "Page note",
+ "updated": "Page note (updated)",
+ "resolved": "Page note (resolved)",
+ "quoteSuffix": "{header} · “{quote}”"
}
},
"harness": {
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index 3a580f7e8..bbe7a31bf 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -17,6 +17,12 @@
"acceptanceUnknown": "Show 事件可能仍在处理中,未在本地重复提交。",
"dispatchFailed": "Show 事件已记录,但未能投递对应的 Agent turn。",
"idConflict": "此 Show 事件 ID 已绑定到不同的事件内容。"
+ },
+ "mark": {
+ "created": "页面批注",
+ "updated": "页面批注(已更新)",
+ "resolved": "页面批注(已处理)",
+ "quoteSuffix": "{header} ·「{quote}」"
}
},
"harness": {