Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { Bell, Power } from "lucide-react";
import { Bell } from "lucide-react";
import { useTranslations } from "next-intl";
import { Switch } from "@/components/ui/switch";
import { cn } from "@/lib/utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useTranslations } from "next-intl";
import { useCallback, useMemo, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import type {
ClientActionResult,
WebhookTargetCreateInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { Button } from "@/components/ui/button";
import { isValidUrl } from "@/lib/utils/validation";
import type { ProviderDisplay, ProviderType } from "@/types/provider";
import { FormTabNav, TAB_CONFIG } from "./components/form-tab-nav";
import { FormTabNav } from "./components/form-tab-nav";
import { ProviderFormProvider, useProviderForm } from "./provider-form-context";
import type { TabId } from "./provider-form-types";
import { BasicInfoSection } from "./sections/basic-info-section";
Expand Down Expand Up @@ -103,7 +103,7 @@ function ProviderFormContent({

const container = contentRef.current;
const containerRect = container.getBoundingClientRect();
const scrollTop = container.scrollTop;
const _scrollTop = container.scrollTop;

// Find which section is at the top of the viewport
let activeSection: TabId = "basic";
Expand All @@ -125,7 +125,7 @@ function ProviderFormContent({
if (state.ui.activeTab !== activeSection) {
dispatch({ type: "SET_ACTIVE_TAB", payload: activeSection });
}
}, [dispatch, state.ui.activeTab, tabOrder]);
}, [dispatch, state.ui.activeTab]);

const handleTabChange = (tab: TabId) => {
dispatch({ type: "SET_ACTIVE_TAB", payload: tab });
Expand Down Expand Up @@ -243,9 +243,12 @@ function ProviderFormContent({
}
toast.success(t("success.updated"));
} else {
// For create: key is required
const createFormData = { ...baseFormData, key: trimmedKey };
const res = await addProvider(createFormData);
// For create: key is required (validated at line 151-152)
if (!trimmedKey) {
toast.error(t("errors.keyRequired"));
return;
}
Comment on lines +247 to +250
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: this runtime check is redundant since validateForm() already ensures trimmedKey is non-empty for create mode (line 151-152), and handleSubmit returns early if validation fails (line 270-274). while it provides defensive programming, it adds unnecessary code that can be removed

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/[locale]/settings/providers/_components/forms/provider-form/index.tsx
Line: 247:250

Comment:
**style:** this runtime check is redundant since `validateForm()` already ensures `trimmedKey` is non-empty for create mode (line 151-152), and `handleSubmit` returns early if validation fails (line 270-274). while it provides defensive programming, it adds unnecessary code that can be removed

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

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

const res = await addProvider({ ...baseFormData, key: trimmedKey });
if (!res.ok) {
toast.error(res.error || t("errors.createFailed"));
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { Context1mPreference } from "@/lib/special-attributes";
import type {
CodexInstructionsStrategy,
CodexParallelToolCallsPreference,
CodexReasoningEffortPreference,
CodexReasoningSummaryPreference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function TimeoutInput({
isCore,
}: TimeoutInputProps) {
const t = useTranslations("settings.providers.form");
const displayValue = value ?? defaultValue;
const _displayValue = value ?? defaultValue;
const isCustom = value !== undefined;

return (
Expand Down