fix(plugin): the session-start Goal line cuts at a word and says where the rest is (#4036)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 8s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 58s
CI & Build / Python tests (push) Successful in 1m27s
CI & Build / Build & push image (push) Successful in 26s

A raw 200-char slice ended mid-word with nothing marking the cut, so a
reader took half a sentence for the whole goal. _goal_line flattens the
goal to one line, trims at a word break with an ellipsis, and points at
enter_project(id) when it cut.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-14 15:34:36 -04:00
co-authored by Claude Opus 5
parent c440c49f5b
commit 21343dc3aa
2 changed files with 49 additions and 1 deletions
+26
View File
@@ -120,6 +120,32 @@ async def test_build_session_context_includes_project_when_scoped():
assert "Reflex:" not in out["context"]
def test_a_short_goal_is_shown_whole():
from scribe.services.plugin_context import _goal_line
assert _goal_line("ship it", 2) == "Goal: ship it"
assert _goal_line("", 2) == ""
def test_a_long_goal_is_cut_at_a_word_and_says_where_the_rest_is():
"""#4036: a raw slice ended mid-word with nothing marking the cut, so a
reader took half a sentence for the whole goal."""
from scribe.services.plugin_context import _GOAL_CHARS, _goal_line
goal = "make the record reach the next session\nso a solution is recalled " * 10
line = _goal_line(goal, 2)
shown = line.removeprefix("Goal: ").split(" (full goal:")[0]
assert shown.endswith("") and len(shown) <= _GOAL_CHARS
# The cut lands between words: what precedes the ellipsis is a whole word.
assert shown[:-1].rstrip().split()[-1] in goal.split()
assert "\n" not in line
assert line.endswith("(full goal: `enter_project(2)`)")
def test_an_unbroken_goal_still_shows_its_start():
from scribe.services.plugin_context import _GOAL_CHARS, _goal_line
shown = _goal_line("x" * 500, 2).removeprefix("Goal: ").split(" (full goal:")[0]
assert shown == "x" * (_GOAL_CHARS - 1) + ""
@pytest.mark.asyncio
async def test_build_session_context_pushes_the_projects_design_system():
"""The gap this closes: a design system had no push channel, so its