Skip to content

Commit 9da4ece

Browse files
committed
refactor: rebase // fix conflicts
1 parent b7b0f67 commit 9da4ece

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

webview-ui/src/components/settings/SettingsView.tsx

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ type SectionName = (typeof sectionNames)[number] // kilocode_change
120120
type SettingsViewProps = {
121121
onDone: () => void
122122
targetSection?: string
123+
editingProfile?: string // kilocode_change - profile to edit
123124
}
124125

125-
const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, targetSection }, ref) => {
126+
// kilocode_change start - editingProfile
127+
const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>((props, ref) => {
128+
const { onDone, targetSection, editingProfile } = props
129+
// kilocode_change end - editingProfile
126130
const { t } = useAppTranslation()
127131

128132
const extensionState = useExtensionState()
@@ -270,8 +274,26 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
270274
setCachedState((prevCachedState) => ({ ...prevCachedState, ...extensionState }))
271275
prevApiConfigName.current = currentApiConfigName
272276
setChangeDetected(false)
273-
setEditingApiConfigName(currentApiConfigName || "default") // kilocode_change: Sync editing profile when active profile changes
274-
}, [currentApiConfigName, extensionState])
277+
// kilocode_change start - Don't reset editingApiConfigName if we have an editingProfile prop (from auth return)
278+
if (!editingProfile) {
279+
setEditingApiConfigName(currentApiConfigName || "default")
280+
}
281+
// kilocode_change end
282+
}, [currentApiConfigName, extensionState, editingProfile]) // kilocode_change
283+
284+
// kilocode_change start: Set editing profile when prop changes (from auth return)
285+
useEffect(() => {
286+
if (editingProfile) {
287+
console.log("[SettingsView] Setting editing profile from prop:", editingProfile)
288+
setEditingApiConfigName(editingProfile)
289+
isLoadingProfileForEditing.current = true
290+
vscode.postMessage({
291+
type: "getProfileConfigurationForEditing",
292+
text: editingProfile,
293+
})
294+
}
295+
}, [editingProfile])
296+
// kilocode_change end
275297

276298
// kilocode_change start
277299
const isLoadingProfileForEditing = useRef(false)
@@ -741,6 +763,32 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
741763
}
742764
}, [targetSection]) // kilocode_change
743765

766+
// kilocode_change start - Listen for messages to restore editing profile after auth
767+
useEffect(() => {
768+
const handleMessage = (event: MessageEvent) => {
769+
const message = event.data
770+
if (
771+
message.type === "action" &&
772+
message.action === "settingsButtonClicked" &&
773+
message.values?.editingProfile
774+
) {
775+
const profileToEdit = message.values.editingProfile as string
776+
console.log("[SettingsView] Restoring editing profile:", profileToEdit)
777+
setEditingApiConfigName(profileToEdit)
778+
// Request the profile's configuration for editing
779+
isLoadingProfileForEditing.current = true
780+
vscode.postMessage({
781+
type: "getProfileConfigurationForEditing",
782+
text: profileToEdit,
783+
})
784+
}
785+
}
786+
787+
window.addEventListener("message", handleMessage)
788+
return () => window.removeEventListener("message", handleMessage)
789+
}, [])
790+
// kilocode_change end
791+
744792
// Function to scroll the active tab into view for vertical layout
745793
const scrollToActiveTab = useCallback(() => {
746794
const activeTabElement = tabRefs.current[activeTab]
@@ -958,7 +1006,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
9581006
setApiConfigurationField={setApiConfigurationField}
9591007
errorMessage={errorMessage}
9601008
setErrorMessage={setErrorMessage}
961-
currentApiConfigName={currentApiConfigName}
1009+
currentApiConfigName={editingApiConfigName}
9621010
/>
9631011
{/* kilocode_change end - pass editing profile name */}
9641012
</Section>

0 commit comments

Comments
 (0)