Skip to content

feat: add Extension settings category with auth token copying and browser integration support#341

Merged
SuperCoolPencil merged 3 commits intomainfrom
reduce-extension-friction
Apr 10, 2026
Merged

feat: add Extension settings category with auth token copying and browser integration support#341
SuperCoolPencil merged 3 commits intomainfrom
reduce-extension-friction

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 10, 2026

Greptile Summary

This PR adds a new Extension settings tab to the TUI, moving ExtensionPrompt from General into a dedicated ExtensionSettings struct, and adding auth-token display/copy-to-clipboard and browser-extension installation links. The AuthToken field is deliberately excluded from JSON serialization via json:"-" and is read from the state file via InitAuthToken() at startup.

The three commits address the previous round's feedback (removed dead ExtensionTokenCopyTimer, fixed JSON exclusion of the auth token, and corrected the ExtensionPrompt field location). Overall the feature is well-structured and handles the main user flows correctly.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/quality suggestions that do not block correct runtime behaviour.

The three previous round findings have all been addressed: AuthToken is now json:"-", ExtensionTokenCopyTimer has been removed, and ExtensionPrompt has been relocated correctly. The two remaining issues (the "-" key produced by json:"-" in metadata, and missing unit tests for new TUI actions) are non-breaking quality improvements.

internal/config/settings.go (json:"-" key extraction) and internal/tui/view_settings.go (same pattern in getSettingsValues at line 593)

Important Files Changed

Filename Overview
internal/config/settings.go Adds ExtensionSettings struct; AuthToken uses json:"-" to fix the previous serialization issue, but this causes GetSettingsMetadata/getSettingsValues to store the field under key "-" instead of a meaningful name.
internal/tui/token.go New file: simple startup-time token cache that reads from the state file once to avoid per-frame disk I/O. Implementation is clean and purposeful.
internal/tui/update_settings.go Adds auth_token copy and link-open handling; imports are all used; flash-fade timer is correctly wired up. No missing edge-case guards for the new code paths.
internal/tui/view_settings.go Extended rendering for auth_token and link types; truncation guard for token display now uses len(token) > 16, safely covering any realistic token length.
internal/tui/update_test.go Correctly updates ExtensionPrompt references to Settings.Extension; no new tests added for the auth_token copy, link-open, or flash-fade behaviors introduced in this PR.
internal/tui/model.go Adds ExtensionTokenCopied flash-state field and calls InitAuthToken() at startup; clean and correct.
internal/utils/open.go Adds OpenBrowser as a thin wrapper over the existing openWithSystem; correct empty-string guard, consistent with the existing OpenFile pattern.
internal/tui/keys.go Adds Tab5 key binding for the Extension tab; FullHelp slice updated accordingly.
extension-chrome/manifest.json Version bump to 1.8.0; permissions and structure unchanged.
extension-firefox/manifest.json Version bump to 1.8.0; CSP and gecko settings unchanged.
internal/config/settings_test.go Good coverage of new ExtensionSettings defaults and round-trip serialization; validates ExtensionPrompt, ChromeExtensionURL, FirefoxExtensionURL, InstructionsURL.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([User presses Enter on Extension tab]) --> B{getCurrentSettingType}
    B -->|auth_token| C[GetAuthToken from cache]
    C --> D{token empty?}
    D -->|yes| E[return nil, no-op]
    D -->|no| F[clipboard.Write token]
    F --> G[ExtensionTokenCopied = true]
    G --> H[tea.Tick 2s → extensionTokenFlashFadeMsg]
    H --> I[ExtensionTokenCopied = false\nUI returns to truncated token display]
    B -->|link| J[getSettingsValues for category]
    J --> K[utils.OpenBrowser url]
    B -->|bool| L[toggle value via setSettingValue]
    B -->|string/int/etc| M[enter edit mode\nSettingsIsEditing = true]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: internal/tui/update_test.go
Line: 356-410

Comment:
**Missing tests for new auth_token and link behaviours**

The PR adds three new code paths in `updateSettings` — auth_token copy-to-clipboard + flash, `extensionTokenFlashFadeMsg` reset of `ExtensionTokenCopied`, and link-open via `OpenBrowser` — but none of them are exercised in the test suite. Per the project's testing rule, edge cases and integration points between components should be covered.

Suggested additions:
- `TestUpdate_ExtensionTokenCopy`: set a non-empty `authTokenCache`, send an `Edit` keypress on the auth_token row, assert `ExtensionTokenCopied == true` and that a `tea.Cmd` is returned.
- `TestUpdate_ExtensionTokenFlashFade`: send `extensionTokenFlashFadeMsg`, assert `ExtensionTokenCopied == false`.
- `TestUpdate_LinkOpen`: send an `Edit` keypress on a `link`-type row, assert `OpenBrowser` was invoked with the expected URL.

**Rule Used:** What: All code changes must include tests for edge... ([source](https://app.greptile.com/review/custom-context?memory=2b22782d-3452-4d55-b059-e631b2540ce8))

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: internal/config/settings.go
Line: 109-114

Comment:
**Reflect tag extraction produces `"-"` as the metadata key for `AuthToken`**

`reflect.StructTag.Get("json")` on a field marked to be skipped during serialization returns the literal hyphen character, not an empty string. The `if key == ""` guard on line 113 never fires for `AuthToken`, so both `GetSettingsMetadata()` and `getSettingsValues()` store that field under key `"-"`.

Today this is non-breaking because every auth_token code path branches on `meta.Type` before touching the key. However, any future key-based switch in the Extension category would need to match `"-"` rather than the intuitive `"auth_token"`. Adding `|| key == "-"` to the empty-string guard (and the equivalent check in `getSettingsValues` in `view_settings.go`) would make the key meaningful and consistent with the rest of the settings metadata.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "style: increase settings modal width and..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

Binary Size Analysis

⚠️ Size Increased

Version Human Readable Raw Bytes
Main 18.95 MB 19865892
PR 18.97 MB 19894564
Difference 28.00 KB 28672

Comment thread internal/tui/view_settings.go
Comment thread internal/tui/model.go Outdated
Comment thread internal/config/settings.go Outdated
@SuperCoolPencil SuperCoolPencil merged commit 25a90eb into main Apr 10, 2026
15 checks passed
@SuperCoolPencil SuperCoolPencil deleted the reduce-extension-friction branch April 10, 2026 20:22
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.

1 participant