Repository navigation
refactor(provider-tui): share model-delete, form rendering and test setup code - #1572
sisantaChhatoi wants to merge 2 commits into
Conversation
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
📄
|
|
Checked this one, and I think it's a false positive. The official path was already resetting the custom-model input before this change. On I'll leave the |
8c06941 to
ad5406f
Compare
Qiyuanqiii
left a comment
There was a problem hiding this comment.
I repeated the comparison against the pre-refactor TUI code, including rendered text, model-delete state transitions, rollback behavior, and the documentation impact.
The earlier automated finding about resetCustomModelInput() is a false positive: the previous official-provider deletion path already called it on success, just like the custom-provider path. The merged implementation therefore preserves that behavior.
I also rechecked the extracted rendering helpers. The labels, indentation, (Authorization) fallback, option rendering, and form-error spacing are preserved.
This is an internal refactor with no user-facing workflow or configuration change, so no documentation update is required.
The new helper and comment wording is clear enough, and I don't have any remaining blocking findings.
Approved.
Merge modelTUIModel's two identical delete-confirm variants, give the provider wizard's two delete paths one save-and-rollback helper, and extract the form field, option list and form error rendering that the custom provider and manual forms each copied.
Extract repeated fixtures, lookups and assertions into helpers, and run the delete-flow and custom-model-input scenarios that were copied per model or per tab from one table-driven test each.
ad5406f to
758a7f5
Compare
|
Heads up on the latest push: it's just a rebase onto current |
Description
Removes duplication in
cmd/opencodereview/provider_tui.goand its tests. The behavior should not change. There are two commits, so the production change can be reviewed separately from the test churn.1.
refactor(provider-tui): production codemodelTUIModel.confirmDeleteCustomProviderModelandconfirmDeleteOfficialModelwere identical apart from the config map they edited. They are merged into the existingconfirmDeleteModel, which picksCustomProvidersorProvidersbyisCustomProvider, the same wayrollbackModelDeletealready did.providerTUIModel.confirmDeleteCustomModelandconfirmDeleteOfficialModeldiffer in their guards and in where the entry lives (the custom path also updates the localcustomProviderscopy and tolerates a nil config), so they are not merged. Their shared tail (save, roll back if the save fails and the config cannot be reloaded, set the error, adjust the index, mark saved) moves intopersistModelDelete(rollback func()), and each passes its own rollback.cfgActiveModelForreplaces the "remember the active model before delete" snippet repeated in three places.formField,writeInactiveFormField,writeOptionListandwriteFormErrorreplace blocks copied betweenviewCustomProviderFormandviewManualTab; the form-error block appeared four times, including once inmodelTUIModel.View. The rendered strings are unchanged.TestModelTUIConfirmDeleteModel_SaveFailureRollbackcovers the merged function's rollback path for both official and custom providers. That path had no test before.2.
test(provider-tui): tests onlyproviderTUIModel(ocr config provider) and again formodelTUIModel(ocr config model). They now run from onedeleteFlowTUItable inprovider_tui_deleteconfirm_test.go, still covering both models (14 subtests).customModelInputTabstable, and the official tab gains the assertions only the custom tab had.TestCollectCustomProviders_NilConfigwas a literal copy ofTestCollectCustomProviders_Niland is removed.newProviderTUIOnTab(81 sites)selectOfficialProviderandselectCustomProvider, which also fail the test when the name is missing instead of silently leaving index 0firstRegistryProvider,activeDeepseekConfig,cpConfigopenCustomProviderForm,fillCustomFormToAuthHeader,sendKey)loadDiskConfig,assertSaveFailed,currentProviderOrSkipassertModels, which compares whole model lists withslices.Equalinstead of partial length and index checksNet diff: +688/−1211.
Type of Change
How Has This Been Tested?
make testpasses locallyEach commit passes
make checkandmake teston its own,go test -race ./cmd/opencodereviewpasses, andmake coveragereports 92.1%. The new rollback test fails if the merged function edits the wrong config map. No previously running test is now skipped: the only skip in the package,TestInterruptChildHarness, is skipped onmainas well.Checklist
go fmt,go vet)AI disclosure: prepared with Claude Code (Claude Opus 5.5). I reviewed every line and can explain each change.
Related Issues
None.
🤖 Generated with Claude Code