fix(tui): apply path/@ completion on Enter

Completion selection on Enter was gated to slash commands only
(value.startsWith('/')), so @file, ./path, and ~/path completions fell
through and submitted the incomplete input instead of inserting the
highlighted row.

Guard on completions.length && compReplace > 0 — useCompletion already
scopes population to slash and path tokens, and the next !== value check
keeps plain-text submits working when the completion is already applied.
This commit is contained in:
Brooklyn Nicholson 2026-04-21 10:42:31 -05:00
parent ce98e1ef11
commit 4b0686f63d
22 changed files with 206 additions and 76 deletions

View file

@ -234,11 +234,11 @@ export function useSubmission(opts: UseSubmissionOptions) {
const submit = useCallback(
(value: string) => {
if (value.startsWith('/') && composerState.completions.length) {
if (composerState.completions.length) {
const row = composerState.completions[composerState.compIdx]
if (row?.text) {
const text = row.text.startsWith('/') && composerState.compReplace > 0 ? row.text.slice(1) : row.text
const text = value.startsWith('/') && row.text.startsWith('/') ? row.text.slice(1) : row.text
const next = value.slice(0, composerState.compReplace) + text
if (next !== value) {