这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@homanp
Copy link
Contributor

@homanp homanp commented Aug 4, 2025

What does this PR do?

This pull request introduces a new feature to handle cursor position within the useInputHandler hook and updates the ChatInput component 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 useInputHandler

  • Added a new state variable cursorPosition to track the cursor's position within the input string and initialized it to 0. ([src/hooks/use-input-handler.tsR46](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R46))
  • Updated various input-resetting code paths to also reset cursorPosition to 0. ([[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))
  • Enhanced input handling logic to:
    • Adjust cursorPosition when 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))
    • Update cursorPosition when selecting a command suggestion. ([src/hooks/use-input-handler.tsL645-R655](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8L645-R655))
  • Exposed cursorPosition in the return object of useInputHandler. ([src/hooks/use-input-handler.tsR748](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-8fdb6362b40b21a0b32d7cf12cb9ea401f968e231a45a40b71af8bd6e8b26bf8R748))

Cursor Display in ChatInput

  • Modified the ChatInput component to:
    • Accept a cursorPosition prop.
    • Split the input string into beforeCursor and afterCursor to 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 cursorPosition in ChatInterfaceWithAgent

  • Passed cursorPosition from useInputHandler to the ChatInput component in ChatInterfaceWithAgent. ([[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

  • Incremented the package version from 0.0.19 to 0.0.20 in package.json. ([package.jsonL3-R3](https://github.com/superagent-ai/grok-cli/pull/64/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L3-R3))

Fixes #57

Checklist

  • I tested my changes
  • I reviewed my own code

@homanp homanp self-assigned this Aug 4, 2025
@homanp homanp merged commit 3ed04b3 into main Aug 4, 2025
2 checks 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.

[Bug]: Cursor keys aren't working

2 participants