fix cursor movement in chat input #64
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This pull request introduces a new feature to handle cursor position within the
useInputHandlerhook and updates theChatInputcomponent to visually represent the cursor. Additionally, the package version has been incremented. The most important changes are grouped below by theme.Cursor Position Management in
useInputHandlercursorPositionto track the cursor's position within the input string and initialized it to0. ([src/hooks/use-input-handler.tsR46](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R46))cursorPositionto0. ([[1]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R90),[[2]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R132),[[3]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R145),[[4]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R174),[[5]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R379),[[6]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R437),[[7]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R454))cursorPositionwhen typing, deleting, or navigating with arrow keys. ([src/hooks/use-input-handler.tsR706-R734](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R706-R734))cursorPositionwhen selecting a command suggestion. ([src/hooks/use-input-handler.tsL645-R655](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8L645-R655))cursorPositionin the return object ofuseInputHandler. ([src/hooks/use-input-handler.tsR748](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R748))Cursor Display in
ChatInputChatInputcomponent to:cursorPositionprop.beforeCursorandafterCursorto visually represent the cursor with a block (█). ([src/ui/components/chat-input.tsxR6-R26](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-6729f0bfe8e0890e7a3fa43631c40e63ad3024f915fbfd955f4c1ca91728d107R6-R26))Integration of
cursorPositioninChatInterfaceWithAgentcursorPositionfromuseInputHandlerto theChatInputcomponent inChatInterfaceWithAgent. ([[1]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-3f8febd4363238d771d92f61817b0d9a7895bc183046426218fc28f97d13ee29R39),[[2]](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-3f8febd4363238d771d92f61817b0d9a7895bc183046426218fc28f97d13ee29R214))Miscellaneous
0.0.19to0.0.20inpackage.json. ([package.jsonL3-R3](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L3-R3))Fixes #57
Checklist