Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(composer): badge a slash word only when it is a real command - #727

Open
Adam-Dalloul wants to merge 1 commit into
xintaofei:mainfrom
Adam-Dalloul:fix/slash-command-only-on-match-or-select
Open

fix(composer): badge a slash word only when it is a real command#727
Adam-Dalloul wants to merge 1 commit into
xintaofei:mainfrom
Adam-Dalloul:fix/slash-command-only-on-match-or-select

Conversation

@Adam-Dalloul

Copy link
Copy Markdown
Contributor

Typing / and a word made it a slash command: text the composer fills itself with (a paste, a restored draft, a quick message, a reopened queued message, a to-do brief) turned any /word into a command badge on shape alone, whether or not the agent had such a command and whether or not anyone picked it from the menu.

A badge now needs the token to be one the agent advertises right now, matched exactly, drawn from the same lists behind the / and $ menus. /rev is not /review; /Review is not /review, since the CLI reads the name it advertised. With no list yet (connection still coming up, or no agent behind the box) nothing is badged, which is the safe direction.

What a badge changes about the message: its text is rebuilt on send from the badge's id rather than carried through, so an id the serializer has to escape (/foo_) goes out as /foo\_. Plain text goes out exactly as written, and stays editable in place instead of becoming one atomic node whose / is hidden.

Unchanged: picking from the menu with Enter, Tab or a click, including the trailing space; badges already in the document, which a list arriving mid-compose never rewrites; file:/codeg: reference links, which hydrate regardless because they were inserted deliberately; and the sent-message transcript, where the text is already fixed.

A bare `/word` became a command badge on shape alone. The composer fills
itself from text in several places -- a paste, a restored draft, a quick
message, a reopened queued message, a to-do brief -- and every one of them
ran the same heuristic: start of line or after a space, `/` or `$`, a
letter, no trailing slash. `/notacommand`, `/etc`, `/nope` all passed, and
the user had picked none of them from the menu. What came back was an
atomic node: the word could no longer be edited in place, its `/` was gone
from the label, and its text was rebuilt on send from the badge's id rather
than kept -- which for an id the serializer has to escape (`/foo_`) is not
even the same bytes.

A badge now requires the token to be one the agent advertises right now,
matched exactly: the tokens behind the `/` and `$` menus themselves, so
what seeded text may become is precisely what the menu could have inserted.
`/rev` is not `/review`, `/Review` is not `/review` (the CLI reads the name
it advertised), and with no list yet -- the connection still coming up, or
no agent behind the box at all -- nothing is badged. That direction is the
safe one: text that stays text is still editable and still sends verbatim.

Picking from the menu is untouched, trailing space included, as are badges
already in the document; a list that lands mid-compose applies to the next
paste and rewrites nothing already written. Reference links keep hydrating
regardless -- a `file:`/`codeg:` destination was inserted deliberately and
says so. The transcript keeps the heuristic on its own: a sent message is
fixed text, and gating it on a list that comes and goes with the connection
would re-badge history underneath the reader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant