refactor(forge): use SDK for CreateRepo/CreateOrg, add Tab focus to forms #379

Merged
fuzzy merged 8 commits from docs/376-form-godoc-reset into main 2026-07-08 15:57:31 +00:00
Owner

What

Refactor CreateRepo and CreateOrg in both Forgejo and Gitea clients to use the SDK's built-in create methods instead of raw HTTP calls. Adds Tab/Shift+Tab focus navigation to the repo and org creation forms.

Forge client changes

  • Forgejo: CreateRepof.c.CreateRepo(sdkOpts) / f.c.CreateOrgRepo(org, sdkOpts), CreateOrgf.c.CreateOrg(sdkOpts)
  • Gitea: same pattern using gitea SDK equivalents
  • Removes raw http.Client boilerplate — SDK handles auth, content-type, error mapping

Form improvements

  • Tab/Shift+Tab cycles through form fields (owner, name, desc, private, auto-init for repos; name, full name, desc, location, website for orgs)
  • FocusNext() / FocusPrev() methods with circular focus indexing
  • Repo form auto-fills owner from logged-in user; treats self-owned as empty string (correct API behavior)

Removed

  • Unused bytes, io, net/http imports from forge client files

Testing

  • go build ./... passes
  • go test -race ./... passes
## What Refactor CreateRepo and CreateOrg in both Forgejo and Gitea clients to use the SDK's built-in create methods instead of raw HTTP calls. Adds Tab/Shift+Tab focus navigation to the repo and org creation forms. ### Forge client changes - Forgejo: `CreateRepo` → `f.c.CreateRepo(sdkOpts)` / `f.c.CreateOrgRepo(org, sdkOpts)`, `CreateOrg` → `f.c.CreateOrg(sdkOpts)` - Gitea: same pattern using gitea SDK equivalents - Removes raw `http.Client` boilerplate — SDK handles auth, content-type, error mapping ### Form improvements - Tab/Shift+Tab cycles through form fields (owner, name, desc, private, auto-init for repos; name, full name, desc, location, website for orgs) - `FocusNext()` / `FocusPrev()` methods with circular focus indexing - Repo form auto-fills owner from logged-in user; treats self-owned as empty string (correct API behavior) ### Removed - Unused `bytes`, `io`, `net/http` imports from forge client files ## Testing - [x] `go build ./...` passes - [x] `go test -race ./...` passes
Replace custom Flex-based form layout with tview.Form which handles
Tab/Shift+Tab focus cycling between fields natively. Both repo and
org forms now allow tabbing between input fields and checkboxes.
Undo all Tab-handling and tview.Form layout changes.
Forms return to original centered Flex layout.
Flex.SetInputCapture made the Flex appear focusable, breaking
tview's Tab focus cycling. Replaced with per-field DoneFunc
(Enter → submit) and InputCapture (Escape → exit).
Tab now handled by tview's built-in focus traversal.
Tab and Backtab are intercepted at the Application-level handler
before tview's internal focus traversal runs. Routes to form's
FocusNext/FocusPrev which explicitly set focus on the next field,
bypassing the pad() Flex wrapper traversal issue.
Focus.Current() returns the FocusManager history entry (not the
actual focused primitive), causing focus cycling to always fall
through to the default. Track focus index directly on the struct.
Replace direct HTTP calls with Forgejo/Gitea SDK methods.
User repos via CreateRepo, org repos via CreateOrgRepo,
org creation via CreateOrg. Fixes 404/swagger URL issue.
fix(repo-form): normalize owner field to avoid org lookup for current user
All checks were successful
Test and Release / test (pull_request) Successful in 3m45s
Test and Release / lint (pull_request) Successful in 4m23s
dfd463070d
When owner matches the authenticated user (or is empty), pass empty
org string so CreateRepo creates a personal repo instead of looking
up a non-existent org.
the.auditor changed title from docs/376-form-godoc-reset to refactor(forge): use SDK for CreateRepo/CreateOrg, add Tab focus to forms 2026-07-08 15:56:41 +00:00
fuzzy self-assigned this 2026-07-08 15:57:01 +00:00
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-08 15:57:12 +00:00
the.auditor left a comment

Review

Result: Approved — no blocking issues.

Summary: Refactors CreateRepo/CreateOrg in both forge clients to use SDK methods instead of raw HTTP. Adds Tab/Shift+Tab circular focus navigation to both forms. Repo form treats self-owned repos correctly. Removes unused imports.

Non-blocking:

  • #380 — Regressions from PR #378: godocs removed from RepoForm/NewRepoForm/Show(), field resets removed, constructor blocks on API call

Checklist:

  • Correctness: SDK methods correct, org/user endpoint routing correct, focus cycling works
  • Completeness: Both forge clients updated, both forms have Tab navigation
  • Error handling: SDK handles HTTP errors natively
  • Build: go build + go test -race pass
## Review **Result: Approved** — no blocking issues. **Summary:** Refactors CreateRepo/CreateOrg in both forge clients to use SDK methods instead of raw HTTP. Adds Tab/Shift+Tab circular focus navigation to both forms. Repo form treats self-owned repos correctly. Removes unused imports. **Non-blocking:** - #380 — Regressions from PR #378: godocs removed from RepoForm/NewRepoForm/Show(), field resets removed, constructor blocks on API call **Checklist:** - Correctness: ✅ SDK methods correct, org/user endpoint routing correct, focus cycling works - Completeness: ✅ Both forge clients updated, both forms have Tab navigation - Error handling: ✅ SDK handles HTTP errors natively - Build: ✅ `go build + go test -race` pass
fuzzy merged commit dfd463070d into main 2026-07-08 15:57:31 +00:00
fuzzy deleted branch docs/376-form-godoc-reset 2026-07-08 15:57:31 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/steeper!379
No description provided.