Skip to content

Fix: skill shortcuts append to existing input instead of overwriting#101

Merged
bbsngg merged 2 commits intoOpenLAIR:mainfrom
renjie-liang:fix/skill-shortcut-overwrite
Mar 26, 2026
Merged

Fix: skill shortcuts append to existing input instead of overwriting#101
bbsngg merged 2 commits intoOpenLAIR:mainfrom
renjie-liang:fix/skill-shortcut-overwrite

Conversation

@renjie-liang
Copy link
Copy Markdown
Contributor

Summary

  • Skill shortcuts in both new session (GuidedPromptStarter) and existing conversation (SkillShortcutsPanel) now append to existing input text instead of replacing it.

Closes #99

🤖 Generated with Claude Code

renjie-liang and others added 2 commits March 25, 2026 18:34
Closes OpenLAIR#99

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use `setInput(prev => ...)` instead of reading DOM via textareaRef to
avoid state/DOM desync. Prepend skill template before existing input so
instructions appear above user's task description. Also add cursor
positioning to SkillShortcutsPanel for consistency with GuidedPromptStarter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bbsngg
Copy link
Copy Markdown
Contributor

bbsngg commented Mar 26, 2026

Code Review & Improvements

已在原 PR 基础上做了以下改进:

1. 用函数式 setInput 替代 DOM 读取

  • setInput(prev => ...) 替代 textareaRef.current?.value,避免 React state 与 DOM 值不同步的潜在风险

2. Skill 模板前置(prepend)

  • 改为 ${prompt}\n\n${prev},skill 指令在前、用户已有文字在后,符合 prompt 自然阅读顺序

3. SkillShortcutsPanel 补齐光标定位

  • 原实现只调用 focus(),现在与 GuidedPromptStarter 保持一致,注入后光标移到文本末尾(setSelectionRange

See commit 102a311.

@bbsngg bbsngg merged commit f4f6f5c into OpenLAIR:main Mar 26, 2026
1 check passed
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.

Skill shortcuts overwrite existing input text instead of appending

2 participants