Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); emrg: gui — fix TUI composer height for multiline input misalignment by argszero · Pull Request #1071 · argszero/emrg · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Agent.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -119,7 +119,7 @@ Community needs voiced in HN agent-UI discussions map directly to EMRG's design:
pkill -f "emrg.server"; rm -f ~/.emrg/emrgd.token; python -m emrg
```

Python: `uv run pytest tests/ -v` (1146) — import check: `uv run python -c "from emrg.client.app import run_client"`
Python: `uv run pytest tests/ -v` (1147) — import check: `uv run python -c "from emrg.client.app import run_client"`
GUI: `cd emrg/gui && npm test` (95: 45 daemon_client + 20 conn-manager + 8 integration + 6 build-config + 7 gui-state + 3 preload-api + 4 boot-contract + 2 theme-guard) — syntax: `node --check main.js preload.js daemon_client.js`
Renderer: `cd emrg/gui/renderer && npm run typecheck && npm test` (476: 5 snapshot-store + 9 utils + 3 ErrorBoundary + 2 App smoke + 11 commands + 4 copywriting + 11 i18n + 11 markdown + 16 transcript + 10 TranscriptView + 15 history + 22 composer + 31 Composer + 6 LinkDialog + 12 sidebar + 17 Sidebar + 9 fileTree + 9 FileTree + 16 resultPanel + 8 ResultPanel + 27 workspaceView + 10 WorkspaceView + 10 dialog + 6 Dialog + 9 ConfirmDialog + 9 RenameDialog + 10 dialogLists + 3 HelpDialog + 9 MemoryDialog + 6 SkillsDialog + 9 openSession + 6 WelcomeDialog + 8 OpenSessionDialog + 7 NewSessionDialog + 7 rewind + 8 RewindDialog + 7 GithubDeviceDialog + 15 daemonBridge + 7 DaemonBridgeProvider + 26 Shell + 15 DialogHost + 20 SettingsPanel + 6 TaskFormDialog + 5 RantDialog + 4 vendorMarkdown) + `npm run build` → `renderer/dist/`
CI: `uv run pytest` (ubuntu + **windows-2025 matrix** — Windows pytest 回归在 PR CI 即失败,v0.2.29 教训 #725) + GUI tests + **actionlint workflow lint** (`rhysd/actionlint@v1.7.12` gate, #444 — workflow 解析错误在 PR CI 即失败,如 `if:` secrets 上下文)
Expand Down
11 changes: 11 additions & 0 deletions emrg/client/python_tui/terminal.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,17 @@ def _get_lines(name: str) -> list[object]:
status_lines = _get_lines("status")[:1]
composer_lines = _get_lines("composer")[:10]
prompt_lines = _get_lines("prompts")[:1]
# rant 2026-08-28T22:53:24 — composer height must track the composer's
# actual rendered line count, not a hard-coded 3. A multiline input
# (text containing "\n", e.g. pasted text or pressing Enter first)
# renders more lines than single-line input; a fixed height makes the
# viewport's region model (composer_height / chat_height / chat_region)
# disagree with what write_lines_to_buffer actually lays out, which is
# the reported "错行" (input content misaligned with the "> " prompt).
# Here we sync the model with reality so every downstream consumer uses
# the correct height. The render loop already computes allocation from
# len(composer_lines) below; this keeps the viewport object in lockstep.
self.viewport.composer_height = len(composer_lines)
# Get ALL chat lines first (without truncation) so we know the real
# needed height. Truncation depends on viewport_height, but
# viewport_height should depend on content — not the other way around.
Expand Down
49 changes: 49 additions & 0 deletions tests/test_terminal_render.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -94,3 +94,52 @@ def test_shutdown_clears_screen():
# 清屏后归位 (0,0):CLEAR_SCREEN 之后必须紧跟 CURSOR_HOME
from emrg.client.python_tui.output import CURSOR_HOME
assert out.index(CLEAR_SCREEN) < out.index(CURSOR_HOME), "clear screen must precede cursor home"


class FakeComposer:
"""Composer fake that mimics InputWidget.render: one top/bottom separator line
plus one Line per logical input line (multi-line text → more than 3 rows).

rant 2026-08-28T22:53:24 — a fixed composer_height=3 mis-models multiline
input; the viewport must track the actual rendered row count.
"""

def __init__(self, text: str) -> None:
self.text = text
self.dirty = True

def render(self, ctx: RenderContext) -> list[Line]:
lines = [Line(spans=[Span(text="─" * ctx.width)])]
# Split on "\n": each logical line, including leading/trailing empty
# strings (matches InputWidget.render's raw = text.split("\n")).
for logical in self.text.split("\n"):
lines.append(Line(spans=[Span(text="> " + logical)]))
lines.append(Line(spans=[Span(text="─" * ctx.width)]))
return lines


def test_composer_height_tracks_multiline_render():
"""viewport.composer_height must reflect the composer's actual line count.

For a single-line input the composer renders 3 rows (sep + content + sep).
For multiline input (text containing "\n") it renders more. A hard-coded
height of 3 would make the viewport's region model disagree with the real
layout → the reported "错行" (composer content misaligned with "> ").
"""
term = Terminal()
term.mount(composer=FakeComposer("hello"))
with redirect_stdout(io.StringIO()):
term.render(full=True)
assert term.viewport.composer_height == 3, "single-line → 3 rows (sep+content+sep)"

term2 = Terminal()
term2.mount(composer=FakeComposer("line1\nline2"))
with redirect_stdout(io.StringIO()):
term2.render(full=True)
assert term2.viewport.composer_height == 4, "2 logical lines → 4 rows"

term3 = Terminal()
term3.mount(composer=FakeComposer("\ntest"))
with redirect_stdout(io.StringIO()):
term3.render(full=True)
assert term3.viewport.composer_height == 4, "leading newline → 4 rows"
Loading