Skip to content

feat: auto-approve non-duplicate extension requests in headless mode#385

Merged
SuperCoolPencil merged 7 commits intomainfrom
fix-extension-server
Apr 20, 2026
Merged

feat: auto-approve non-duplicate extension requests in headless mode#385
SuperCoolPencil merged 7 commits intomainfrom
fix-extension-server

Conversation

@SuperCoolPencil
Copy link
Copy Markdown
Member

@SuperCoolPencil SuperCoolPencil commented Apr 18, 2026

Close #384

Greptile Summary

This PR adds headless-mode (no TUI) auto-approval logic for extension download requests: non-duplicate URLs are approved automatically, while duplicates are rejected with 409 Conflict. To support this, CheckForDuplicate was refactored to always perform its DB scan and delegate policy decisions (warn, block, auto-approve) entirely to the caller.

  • The unresolved concern from the previous review thread remains: update_input.go (line 99) and update_modals.go (line 86) call checkForDuplicate without a WarnOnDuplicate guard, so with CheckForDuplicate now always scanning, these TUI paths will surface the duplicate warning dialog even when the user has WarnOnDuplicate=false.

Confidence Score: 4/5

Safe to merge once the TUI regression from the CheckForDuplicate refactor is resolved

The headless-mode logic in root_downloads.go and all three new tests are correct. However, the prior-review P1 finding — that removing the WarnOnDuplicate early return from CheckForDuplicate breaks the unguarded TUI call sites in update_input.go and update_modals.go — remains unaddressed in this revision, keeping the score at 4.

internal/processing/duplicate.go and internal/tui/helpers.go (and its callers update_input.go:99, update_modals.go:86)

Important Files Changed

Filename Overview
internal/processing/duplicate.go Removes WarnOnDuplicate early-return, making CheckForDuplicate always scan regardless of settings — correct for headless mode but breaks TUI callers that relied on nil return to skip duplicate UI (flagged in prior review threads)
cmd/root_downloads.go Adds headless-mode branch in maybeRequireDownloadApproval: auto-approves non-duplicate extension requests and returns 409 for duplicates when no TUI is running; logic and conditions are correct
cmd/headless_approval_test.go Adds three headless-mode tests covering auto-approve for non-duplicate, reject for duplicate+WarnOnDuplicate, and reject for duplicate+ExtensionPrompt+WarnOnDuplicate=false; coverage is thorough for the new code path
cmd/http_handler_test.go Unchanged tests; no new issues introduced
internal/tui/helpers.go checkForDuplicate delegates to processing.CheckForDuplicate without any WarnOnDuplicate guard; now that CheckForDuplicate always scans, call sites in update_input.go and update_modals.go will trigger duplicate UI even when WarnOnDuplicate=false (unresolved concern from prior review)

Comments Outside Diff (1)

  1. cmd/root_downloads.go, line 244-248 (link)

    P2 Stale "or approval required" in error message

    After this change, the 409 path is only reachable when isDuplicate=true — non-duplicates are now auto-approved above. The "or approval required" clause in the message no longer corresponds to any real code path and will confuse callers trying to diagnose a rejection.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: cmd/root_downloads.go
    Line: 244-248
    
    Comment:
    **Stale "or approval required" in error message**
    
    After this change, the 409 path is only reachable when `isDuplicate=true` — non-duplicates are now auto-approved above. The "or approval required" clause in the message no longer corresponds to any real code path and will confuse callers trying to diagnose a rejection.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

Reviews (6): Last reviewed commit: "refactor: standardize global state clean..." | Re-trigger Greptile

Comment thread cmd/headless_approval_test.go
@SuperCoolPencil SuperCoolPencil force-pushed the fix-extension-server branch 2 times, most recently from 3e4df89 to 4787f9c Compare April 20, 2026 07:15
Comment thread internal/processing/duplicate.go Outdated
@SuperCoolPencil
Copy link
Copy Markdown
Member Author

this is already resolved.

@SuperCoolPencil SuperCoolPencil merged commit bf375b4 into main Apr 20, 2026
16 checks passed
@SuperCoolPencil SuperCoolPencil deleted the fix-extension-server branch April 20, 2026 14:45
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.

Cant download files when using surge server with extension

1 participant