Skip to content

Text Highlight: Update Highlighted Text Behavior#339

Merged
lk340 merged 7 commits intomainfrom
feature/text-highlight/updated-input-view-behavior
Jul 18, 2025
Merged

Text Highlight: Update Highlighted Text Behavior#339
lk340 merged 7 commits intomainfrom
feature/text-highlight/updated-input-view-behavior

Conversation

@lk340
Copy link
Collaborator

@lk340 lk340 commented Jul 16, 2025

This is part 1 in a series of mini-PRs that tackle various aspects of the overarching text highlight context experience.
Please review this first before reviewing all other text highlight PRs.

Part 2: #340

Summary

  • The inputView can now be permanently shown or hidden.
  • inputView is permanently hidden when closing it through the newly-added cross ("x") button in the inputView title section.
  • Highlighted text now appears as a context tag in FileRow.
  • Clicking on the highlighted text context item reveals the inputView.
  • inputView showing/hiding can also be toggled in the settings "General" tab, under the "Highlighted Text" section.

Parts (Pin 1 and Pin 2 have been closed)

  1. YOU ARE HERE
  2. Text Highlight: Auto-add To Context #340
  3. Text Highlight (Pin - 1): Update to Data Files and OnitPanelState #342 (Pin 1)
  4. Text Highlight (Pin - 2): Update to Managers and UI #343 (Pin 2)
  5. Text Highlight: Pin #341 (Pin 3)

* Add `showHighlightedTextInput` Defaults property. This handles the permanent showing/hiding of the `inputView`.
* `inputView` can now be permanently hidden.
* Update settings "General" tab to allow for toggling of `showHighlightedTextInput` boolean, which determines the show/hide behavior of `inputView`.
* FileRow now shows highlighted text as a ContextTag. Clicking on the ContextTag toggles `showHighlightedTextInput` to `true`, revealing the `inputView` if it were hidden.
@lk340 lk340 requested a review from timlenardo July 16, 2025 19:59
@lk340 lk340 self-assigned this Jul 16, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR introduces a significant enhancement to the text highlighting feature by adding persistent visibility control for the inputView. The changes span across several files to implement two key mechanisms for controlling the input view's visibility:

  1. A new close button ("x") in the inputView title section
  2. A toggle switch in the Settings > General tab

The implementation also introduces a new UI pattern where highlighted text appears as a context tag in FileRow, positioned between pending and added window context items. This improves the discoverability and interaction model for highlighted text.

The changes are well-structured across the codebase:

  • Adds persistent state management via Defaults.Keys
  • Implements UI controls in both the input view and settings
  • Maintains consistent styling and follows existing patterns

Confidence score: 5/5

  1. This PR is extremely safe to merge as it follows existing patterns and primarily adds UI control features
  2. The changes are well-isolated, properly implemented, and don't modify any critical application logic
  3. Key files to review: InputButtons.swift and GeneralTab.swift for the new UI controls

4 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

Comment on lines 210 to 211
text: pendingInput.selectedText,
iconView: Image(.text).addIconStyles(iconSize: 14)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Since this is dark mode only app, text should have an explicit foregroundColor or foregroundStyle set

Copy link
Contributor

@timlenardo timlenardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lk340 - thanks so much for splitting up the original PR. This one is MUCH easier to review.
I have two small change requests:

  1. Can you update the buttons in InputButtons per my comments in Slack?
  2. There's an edge case the occurs when the text that you've highlighted starts with a newline. The logic that you have to determine what gets displayed in the tag uses the empty characters, and you end up with an empty tag. Here's an screenshot illustrating the issue:
Screenshot 2025-07-16 at 1 36 12 PM

Can you update it to ignore empty lines and whitespace? We should call something like '.trim()' on the input string to remove leading whitespace, and also ignore new lines inside the string when creating the preview.

* Fix whitespace and new lines being included in highlighted text.
* Remove copy and close buttons in InputTitle. Caret button no longer toggles height of `inputView`; it now handles removing the `inputView` from the UI (previous close button behavior).
* Because the caret button no longer toggles the height of `inputView`, height toggle logic has been removed.
Copy link
Contributor

@timlenardo timlenardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two changes requested:

  1. We can't strip the newlines and spaces in AccessibilityNotificationManager- we want to send the unedited text to the LLM. Instead, we should do that in the views that display them.
  2. We need to make InputView and InputButtons work in FinalContextView, too.

Regarding your questions in Slack:

  1. x vs carrot - let's keep the carrot since it's more descriptive in the context of FinalContextView.
  2. contextTag vs. inputView - By 'preview' I meant the tag. I don't think we need to remove spaces in the InputView itself.
  3. replace multi-spaces with single space - Since it's getting complex, I would recommend only removing spaces for the context tag as discussed in point 2. Then you don't have to deal with this issue. In the full InputView, the spaces are helpful, particularly when it's code.

lk340 and others added 4 commits July 18, 2025 08:59
* Add toggle feature to auto-adding of highlighted text to context.
* Add new `autoAddHighlightedTextToContext` boolean property to Defaults store. Property defaults to `true`.
* Add new switch button to settings "General" tab to toggle `autoAddHighlightedTextToContext` boolean.
* Add new `trackedPendingInput` property to OnitPanelState to track highlighted text when `autoAddHighlightedTextToContext` is `false`.
* When `autoAddHighlightedTextToContext` is `false`, highlighting text reveals the "ghost" context tag in FileRow to manually add highlighted text to context.
* When `autoAddHighlightedTextToContext` is `true`, the app maintains previous highlight behavior (auto-adding to context). If some text was already highlighted, this switch will automatically add the highlighted text to context.
* Update highlighted text ContextTag to have a remove action for highlighted text context.
* Update to show both ghost tags in FileRow.
* Remove trimming on the `processSelectedText()` level and apply it only on the context tags level instead.
* Add new StringHelpers struct for reusable removable of whitespace + new lines.
* Update ordering of context tags in FileRow.
* Update hiding of InputView to the PromptCore level. InputView can now be seen in the FinalContextView, regardless of show state.
* Update InputView to be a collapsible element when in FinalContextView.
* Increase max height of InputView.
* `highlightedTextContext` button now shows border when InputView is active. Update ContextTag to make this type of update more reusable.
* Update `inputString` output in InputTitle.
* Update background, borders and spacing around InputView.
* InputView is now inside of PromptCore to reflect design updates.
* Update spacing in PromptCore.
Copy link
Contributor

@timlenardo timlenardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks for tackling all this @lk340 ⭐️

@lk340 lk340 merged commit 7fbabb5 into main Jul 18, 2025
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.

2 participants