fix(opencode): the 2.x home placeholder is not typed input, cut example included (Issue #60, Linux item 1)
An adapter can now name its placeholder as a pattern the box's first line matches in full (input_placeholder_pattern); input_placeholder stays the literal lib.sh greps for. opencode: `Ask anything… "<example>"`, the closing quote optional because a box under ~65 columns cuts the example. Fixtures: the 140-column herdr capture and a 60-column one with the cut example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d49abb371
commit
14d7a46181
6 files changed
+170
-2
No files matched your search
@@ -50,6 +50,12 @@ class OpenCodeAgentAdapter(BaseAgentAdapter):
|
||||
def input_placeholder(self) -> Optional[str]:
|
||||
return ''
|
||||
|
||||
@property
|
||||
def input_placeholder_pattern(self) -> Optional[str]:
|
||||
# 2.x home screen: `Ask anything… "<example>"`, the example picked per
|
||||
# launch and cut without its closing quote in a narrow box (Issue #60).
|
||||
return r'Ask anything(?:…|\.\.\.)(?: "[^"]*"?)?'
|
||||
|
||||
@property
|
||||
def input_rule_pattern(self) -> Optional[str]:
|
||||
# Kept for lib.sh's readiness corroboration; the input box itself is a
|
||||
|
||||
@@ -208,6 +208,13 @@ class BaseAgentAdapter:
|
||||
def input_placeholder(self) -> Optional[str]:
|
||||
return None
|
||||
|
||||
@property
|
||||
def input_placeholder_pattern(self) -> Optional[str]:
|
||||
"""Regex the input box's first line matches in full while it shows
|
||||
only a placeholder whose text varies (#60); input_placeholder stays
|
||||
the literal lib.sh greps for."""
|
||||
return None
|
||||
|
||||
@property
|
||||
def input_rule_pattern(self) -> Optional[str]:
|
||||
return None
|
||||
|
||||
@@ -17,7 +17,8 @@ def extract_input_region(pane_text: str, agent_name: str) -> str:
|
||||
prompt line is input: a multi-line draft is never cut to its first line.
|
||||
|
||||
Then `input_frame_chars` are stripped, and the prompt and the placeholder
|
||||
(whole-line) are stripped from the box's first non-blank line only. There
|
||||
(whole-line: `input_placeholder` exactly or `input_placeholder_pattern` in
|
||||
full) are stripped from the box's first non-blank line only. There
|
||||
is no whole-pane fallback: a pane with none of these shapes has no input
|
||||
region and yields a non-empty "unknown" result rather than a guess.
|
||||
Raises ValueError for agents without input area facts (like hermes' peers).
|
||||
@@ -79,7 +80,8 @@ def extract_input_region(pane_text: str, agent_name: str) -> str:
|
||||
if first is not None:
|
||||
head = re.sub(r'^\s*' + re.escape(prompt) + r'\s*', '', region_lines[first], count=1)
|
||||
placeholder = adapter.input_placeholder
|
||||
if placeholder and head.strip() == placeholder:
|
||||
pattern = adapter.input_placeholder_pattern
|
||||
if (placeholder and head.strip() == placeholder) or (pattern and re.fullmatch(pattern, head.strip())):
|
||||
head = ''
|
||||
region_lines[first] = head
|
||||
|
||||
|
||||
Reference in new issue
Block a user