From 11e71b4b9656fabfdb3c826b1f586577c0b0d1f4 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 14 Sep 2026 21:31:47 -0700 Subject: [PATCH] Add feature hints for sync, variables, encryption, and chaining --- .../commands/openWorkspaceSettings.tsx | 12 ++- apps/yaak-client/components/DynamicForm.tsx | 27 +++++- .../components/EnvironmentEditor.tsx | 18 ++++ .../components/HttpAuthenticationEditor.tsx | 1 + .../components/HttpRequestPane.tsx | 40 ++++---- .../components/HttpResponsePane.tsx | 2 + .../components/SyncToFilesystemSetting.tsx | 1 + .../components/WorkspaceSettingsDialog.tsx | 21 +++- .../components/core/DismissibleBanner.tsx | 96 +++++++++++-------- .../components/core/FeatureHint.tsx | 78 +++++++++++++++ .../components/core/SettingRow.tsx | 46 ++++++++- .../components/git/GitDropdown.tsx | 63 +----------- .../components/hints/ChainingHint.tsx | 29 ++++++ .../components/hints/SecretVariableHint.tsx | 44 +++++++++ .../components/hints/SharedOriginHint.tsx | 73 ++++++++++++++ .../components/hints/SyncWorkspaceHint.tsx | 44 +++++++++ .../lib/addVariableToBaseEnvironment.ts | 31 ++++++ packages/tailwind-config/index.css | 13 +++ packages/theme/src/window.ts | 5 +- 19 files changed, 513 insertions(+), 131 deletions(-) create mode 100644 apps/yaak-client/components/core/FeatureHint.tsx create mode 100644 apps/yaak-client/components/hints/ChainingHint.tsx create mode 100644 apps/yaak-client/components/hints/SecretVariableHint.tsx create mode 100644 apps/yaak-client/components/hints/SharedOriginHint.tsx create mode 100644 apps/yaak-client/components/hints/SyncWorkspaceHint.tsx create mode 100644 apps/yaak-client/lib/addVariableToBaseEnvironment.ts diff --git a/apps/yaak-client/commands/openWorkspaceSettings.tsx b/apps/yaak-client/commands/openWorkspaceSettings.tsx index 1af368f43..d643caea8 100644 --- a/apps/yaak-client/commands/openWorkspaceSettings.tsx +++ b/apps/yaak-client/commands/openWorkspaceSettings.tsx @@ -1,10 +1,16 @@ -import type { WorkspaceSettingsTab } from "../components/WorkspaceSettingsDialog"; +import type { + WorkspaceSettingsHighlight, + WorkspaceSettingsTab, +} from "../components/WorkspaceSettingsDialog"; import { WorkspaceSettingsDialog } from "../components/WorkspaceSettingsDialog"; import { activeWorkspaceIdAtom } from "../hooks/useActiveWorkspace"; import { jotaiStore } from "../lib/jotai"; -export function openWorkspaceSettings(tab?: WorkspaceSettingsTab) { +export function openWorkspaceSettings( + tab?: WorkspaceSettingsTab, + highlight?: WorkspaceSettingsHighlight, +) { const workspaceId = jotaiStore.get(activeWorkspaceIdAtom); if (workspaceId == null) return; - WorkspaceSettingsDialog.show(workspaceId, tab); + WorkspaceSettingsDialog.show(workspaceId, tab, highlight); } diff --git a/apps/yaak-client/components/DynamicForm.tsx b/apps/yaak-client/components/DynamicForm.tsx index adb314148..ccad8379d 100644 --- a/apps/yaak-client/components/DynamicForm.tsx +++ b/apps/yaak-client/components/DynamicForm.tsx @@ -31,6 +31,7 @@ import type { Pair } from "./core/PairEditor"; import { PairEditor } from "./core/PairEditor"; import { PlainInput } from "./core/PlainInput"; import { Select } from "./core/Select"; +import { SecretVariableHint } from "./hints/SecretVariableHint"; import { Markdown } from "./Markdown"; import { SelectFile } from "./SelectFile"; @@ -46,6 +47,8 @@ interface Props { stateKey: string; className?: string; disabled?: boolean; + /** Offer to move literal secrets typed into password fields into a variable */ + suggestVariables?: boolean; } export function DynamicForm>({ @@ -57,6 +60,7 @@ export function DynamicForm>({ stateKey, className, disabled, + suggestVariables, }: Props) { const setDataAttr = useCallback( (name: string, value: JsonPrimitive) => { @@ -73,6 +77,7 @@ export function DynamicForm>({ stateKey={stateKey} autocompleteFunctions={autocompleteFunctions} autocompleteVariables={autocompleteVariables} + suggestVariables={suggestVariables} data={data} className={classNames(className, "pb-4")} // Pad the bottom to look nice /> @@ -103,6 +108,7 @@ type FormInputsProps = Pick< > & { setDataAttr: (name: string, value: JsonPrimitive) => void; disabled?: boolean; + suggestVariables?: boolean; }; function FormInputs>({ @@ -113,6 +119,7 @@ function FormInputs>({ setDataAttr, data, disabled, + suggestVariables, }: FormInputsProps) { return ( <> @@ -147,6 +154,7 @@ function FormInputs>({ arg={input} autocompleteFunctions={autocompleteFunctions || false} autocompleteVariables={autocompleteVariables || false} + suggestVariables={suggestVariables || false} onChange={(v) => setDataAttr(input.name, v)} value={ data[input.name] != null ? String(data[input.name]) : (input.defaultValue ?? "") @@ -287,6 +295,7 @@ function TextArg({ value, autocompleteFunctions, autocompleteVariables, + suggestVariables, stateKey, }: { arg: FormInputText; @@ -294,6 +303,7 @@ function TextArg({ onChange: (v: string) => void; autocompleteFunctions: boolean; autocompleteVariables: boolean; + suggestVariables: boolean; stateKey: string; }) { const props: InputProps = { @@ -316,10 +326,19 @@ function TextArg({ autocompleteFunctions, autocompleteVariables, }; - if (autocompleteVariables || autocompleteFunctions || arg.completionOptions) { - return ; - } - return ; + const input = + autocompleteVariables || autocompleteFunctions || arg.completionOptions ? ( + + ) : ( + + ); + if (!suggestVariables || !arg.password) return input; + return ( +
+ {input} + +
+ ); } function EditorArg({ diff --git a/apps/yaak-client/components/EnvironmentEditor.tsx b/apps/yaak-client/components/EnvironmentEditor.tsx index d22a98992..8f67b4378 100644 --- a/apps/yaak-client/components/EnvironmentEditor.tsx +++ b/apps/yaak-client/components/EnvironmentEditor.tsx @@ -15,6 +15,7 @@ import { withEncryptionEnabled, } from "../lib/setupOrConfigureEncryption"; import { DismissibleBanner } from "./core/DismissibleBanner"; +import { FeatureHint } from "./core/FeatureHint"; import type { GenericCompletionConfig } from "./core/Editor/genericCompletion"; import type { PairEditorHandle, PairWithId } from "./core/PairEditor"; import { ensurePairId } from "./core/PairEditor.util"; @@ -152,6 +153,17 @@ export function EnvironmentEditor({ environment, hideName, className, setRef }: This sharable environment contains plain-text secrets )} + {!environment.public && !isEncryptionEnabled && hasSecretLookingVariable(environment) && ( + + Some of these look like secrets. Encrypt them so the workspace is safe to sync to a + folder or share with a team. + + )} ); } + +const SECRET_NAME = /token|secret|password|passwd|api[_-]?key|private[_-]?key|credential/i; + +function hasSecretLookingVariable(environment: Environment) { + return environment.variables.some((v) => v.value.trim() !== "" && SECRET_NAME.test(v.name)); +} diff --git a/apps/yaak-client/components/HttpAuthenticationEditor.tsx b/apps/yaak-client/components/HttpAuthenticationEditor.tsx index 0da989bcc..5c77b29c6 100644 --- a/apps/yaak-client/components/HttpAuthenticationEditor.tsx +++ b/apps/yaak-client/components/HttpAuthenticationEditor.tsx @@ -178,6 +178,7 @@ export function HttpAuthenticationEditor({ model }: Props) { disabled={model.authentication.disabled === true} autocompleteVariables autocompleteFunctions + suggestVariables stateKey={`auth.${model.id}.${model.authenticationType}`} inputs={authConfig.data?.args ?? []} data={model.authentication} diff --git a/apps/yaak-client/components/HttpRequestPane.tsx b/apps/yaak-client/components/HttpRequestPane.tsx index 494b469e5..da4937a4c 100644 --- a/apps/yaak-client/components/HttpRequestPane.tsx +++ b/apps/yaak-client/components/HttpRequestPane.tsx @@ -52,6 +52,7 @@ import { JsonBodyEditor } from "./JsonBodyEditor"; import { MarkdownEditor } from "./MarkdownEditor"; import { RequestMethodDropdown } from "./RequestMethodDropdown"; import { countOverriddenSettings, ModelSettingsEditor } from "./ModelSettingsEditor"; +import { SharedOriginHint } from "./hints/SharedOriginHint"; import { UrlBar } from "./UrlBar"; import { UrlParametersEditor } from "./UrlParameterEditor"; @@ -344,24 +345,27 @@ export function HttpRequestPane({ style, fullHeight, className, activeRequest }: > {activeRequest && ( <> - - - - } - forceUpdateKey={updateKey} - isLoading={activeResponse != null && activeResponse.state !== "closed"} - /> +
+ + +
+ } + forceUpdateKey={updateKey} + isLoading={activeResponse != null && activeResponse.state !== "closed"} + /> + + )} + {activeResponse && } {/* Show tabs if we have any data (headers, body, etc.) even if there's an error */} void; tab?: WorkspaceSettingsTab; + highlight?: WorkspaceSettingsHighlight; } +/** Settings rows that can be pointed out when the dialog opens */ +export type WorkspaceSettingsHighlight = "sync_dir"; + const TAB_AUTH = "auth"; const TAB_DNS = "dns"; const TAB_HEADERS = "headers"; @@ -42,7 +46,7 @@ export type WorkspaceSettingsTab = const DEFAULT_TAB: WorkspaceSettingsTab = TAB_GENERAL; -export function WorkspaceSettingsDialog({ workspaceId, hide, tab }: Props) { +export function WorkspaceSettingsDialog({ workspaceId, hide, tab, highlight }: Props) { const workspace = useAtomValue(workspacesAtom).find((w) => w.id === workspaceId); const workspaceMeta = useAtomValue(workspaceMetasAtom).find((m) => m.workspaceId === workspaceId); const authTab = useAuthTab(TAB_AUTH, workspace ?? null); @@ -104,7 +108,7 @@ export function WorkspaceSettingsDialog({ workspaceId, hide, tab }: Props) { /> - + { +WorkspaceSettingsDialog.show = ( + workspaceId: string, + tab?: WorkspaceSettingsTab, + highlight?: WorkspaceSettingsHighlight, +) => { showDialog({ id: "workspace-settings", size: "lg", className: "h-[calc(100vh-5rem)] max-h-200!", noPadding: true, render: ({ hide }) => ( - + ), }); }; diff --git a/apps/yaak-client/components/core/DismissibleBanner.tsx b/apps/yaak-client/components/core/DismissibleBanner.tsx index f2d18712f..298249006 100644 --- a/apps/yaak-client/components/core/DismissibleBanner.tsx +++ b/apps/yaak-client/components/core/DismissibleBanner.tsx @@ -2,11 +2,12 @@ import type { Color } from "@yaakapp-internal/plugins"; import type { BannerProps } from "@yaakapp-internal/ui"; import { Banner } from "@yaakapp-internal/ui"; import classNames from "classnames"; -import type { MouseEvent } from "react"; +import type { MouseEvent, ReactNode } from "react"; import { useEffect } from "react"; import { useKeyValue } from "../../hooks/useKeyValue"; import type { ButtonProps } from "./Button"; import { Button } from "./Button"; +import { IconButton } from "./IconButton"; type DismissibleBannerSize = "sm" | "xs"; @@ -18,17 +19,21 @@ export function DismissibleBanner({ onDismiss, onShow, actions, + variant = "banner", ...props }: BannerProps & { id: string; size?: DismissibleBannerSize; onDismiss?: () => void | Promise; onShow?: () => void | Promise; + /** A tip dismisses with an X in the corner instead of a text button */ + variant?: "banner" | "tip"; actions?: { label: string; onClick: () => void; color?: Color; variant?: ButtonProps["variant"]; + rightSlot?: ReactNode; }[]; }) { const { @@ -56,54 +61,69 @@ export function DismissibleBanner({ event.preventDefault(); event.stopPropagation(); }; + const dismiss = (event: MouseEvent) => { + stopParentClick(event); + setDismissed(true).catch(console.error); + Promise.resolve(onDismiss?.()).catch(console.error); + }; + const isTip = variant === "tip"; + const hasActionRow = !isTip || (actions?.length ?? 0) > 0; return ( -
+
+ {isTip && ( + + )}
- {children} -
- - {actions?.map((a) => ( - - ))} -
+ {isTip ?
{children}
: children} + {hasActionRow && ( +
+ {!isTip && ( + + )} + {actions?.map((a) => ( + + ))} +
+ )}
diff --git a/apps/yaak-client/components/core/FeatureHint.tsx b/apps/yaak-client/components/core/FeatureHint.tsx new file mode 100644 index 000000000..7c13cfaab --- /dev/null +++ b/apps/yaak-client/components/core/FeatureHint.tsx @@ -0,0 +1,78 @@ +import { platform } from "@yaakapp-internal/platform"; +import { Icon } from "@yaakapp-internal/ui"; +import type { ReactNode } from "react"; +import { setKeyValue } from "../../lib/keyValueStore"; +import { DismissibleBanner } from "./DismissibleBanner"; + +interface Props { + /** Stable id; the dismissal is remembered under it. */ + id: string; + children: ReactNode; + docsUrl?: string; + action?: { label: string; onClick: () => void | Promise }; + onDismiss?: () => void; + className?: string; +} + +/** + * A one-time nudge toward a feature the user hasn't found yet. Dismissed once, gone for good. + */ +export function FeatureHint({ id, children, docsUrl, action, onDismiss, className }: Props) { + const actions = [ + ...(action ? [{ ...action, variant: "solid" as const, color: "info" as const }] : []), + ...(action != null && docsUrl != null + ? [ + { + label: "Docs", + rightSlot: , + onClick: () => platform.openUrl(docsUrl).catch(console.error), + }, + ] + : []), + ]; + return ( + +
+ +
+ {children} + {action == null && docsUrl != null && ( + <> + {" "} + ( + + ) + + )} +
+
+
+ ); +} + +export function dismissFeatureHint(id: string) { + return setKeyValue({ + namespace: "global", + key: ["dismiss-banner", `feature-hint:${id}`], + value: true, + }); +} diff --git a/apps/yaak-client/components/core/SettingRow.tsx b/apps/yaak-client/components/core/SettingRow.tsx index bc463e610..5bb37d676 100644 --- a/apps/yaak-client/components/core/SettingRow.tsx +++ b/apps/yaak-client/components/core/SettingRow.tsx @@ -2,6 +2,7 @@ import type { AnyModel } from "@yaakapp-internal/models"; import { patchModel } from "@yaakapp-internal/models"; import classNames from "classnames"; import type { ReactNode } from "react"; +import { createContext, useContext, useEffect, useRef, useState } from "react"; import { CopyIconButton } from "../CopyIconButton"; import { Checkbox } from "./Checkbox"; import { IconButton, type IconButtonProps } from "./IconButton"; @@ -19,11 +20,31 @@ type SettingRowBaseProps = { controlClassName?: string; description?: ReactNode; disabled?: boolean; + /** Matched against the surrounding `SettingsList` highlight to point this row out when it opens */ + highlightKey?: string; title: ReactNode; }; -export function SettingsList({ children, className }: { children: ReactNode; className?: string }) { - return
{children}
; +const SettingsHighlightContext = createContext(null); + +const FOCUSABLE = + "button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])"; + +export function SettingsList({ + children, + className, + highlight = null, +}: { + children: ReactNode; + className?: string; + /** The `highlightKey` of a row to scroll to, focus, and briefly highlight */ + highlight?: string | null; +}) { + return ( + +
{children}
+
+ ); } export function SettingsSection({ @@ -58,17 +79,37 @@ export function SettingRow({ controlClassName, description, disabled, + highlightKey, title, }: { children: ReactNode; } & SettingRowBaseProps) { + const highlight = useContext(SettingsHighlightContext); + const isHighlighted = highlightKey != null && highlightKey === highlight; + const [flashing, setFlashing] = useState(isHighlighted); + const rowRef = useRef(null); + const controlRef = useRef(null); + + useEffect(() => { + if (!isHighlighted) return; + rowRef.current?.scrollIntoView({ block: "nearest" }); + controlRef.current?.querySelector(FOCUSABLE)?.focus(); + }, [isHighlighted]); + return (
{ + if (event.target === event.currentTarget) setFlashing(false); + }} className={classNames( className, "@container border-b border-border-subtle py-4", disabled && "opacity-disabled", + // Drawn on a layer so the tint gets even padding and stops short of the row's border + flashing && + "relative isolate before:absolute before:-inset-x-3 before:inset-y-1 before:-z-10 before:rounded-lg before:animate-settingHighlight", )} >
; + return ; } return ; @@ -567,64 +566,6 @@ const GitMenuButton = forwardRef>({ - key: "setup_sync", - fallback: {}, - }); - - if (hidden == null || hidden[workspaceMeta.workspaceId]) { - return null; - } - - const banner = ( - - When enabled, workspace data syncs to the chosen folder as text files, ideal for backup and - Git collaboration. - - ); - - return ( - , - onSelect: () => openWorkspaceSettings("settings"), - }, - { type: "separator" }, - { - label: "Hide This Message", - leftSlot: , - async onSelect() { - const confirmed = await showConfirm({ - id: "hide-sync-menu-prompt", - title: "Hide Setup Message", - description: "You can configure filesystem sync or Git it in the workspace settings", - }); - if (confirmed) { - await setHidden((prev) => ({ ...prev, [workspaceMeta.workspaceId]: true })); - } - }, - }, - ]} - > - -
- -
Setup FS Sync or Git
-
-
-
- ); -} - function SetupGitDropdown({ workspaceId, initRepo, diff --git a/apps/yaak-client/components/hints/ChainingHint.tsx b/apps/yaak-client/components/hints/ChainingHint.tsx new file mode 100644 index 000000000..e1a3df184 --- /dev/null +++ b/apps/yaak-client/components/hints/ChainingHint.tsx @@ -0,0 +1,29 @@ +import type { HttpResponse } from "@yaakapp-internal/models"; +import { httpRequestsAtom } from "@yaakapp-internal/models"; +import { InlineCode } from "@yaakapp-internal/ui"; +import { useAtomValue } from "jotai"; +import { FeatureHint } from "../core/FeatureHint"; + +const MIN_REQUESTS = 2; +const DOCS_URL = "https://yaak.app/docs/templating/request-chaining-scripting"; + +interface Props { + response: HttpResponse; + mimeType: string | null; +} + +/** A successful JSON response, in a workspace with somewhere to send its values. */ +export function ChainingHint({ response, mimeType }: Props) { + const requestCount = useAtomValue(httpRequestsAtom).length; + const status = response.status ?? 0; + const isJson = mimeType != null && /json/i.test(mimeType); + if (response.state !== "closed" || status < 200 || status >= 300) return null; + if (!isJson || requestCount < MIN_REQUESTS) return null; + + return ( + + Need a value from here in another request? Press Ctrl+Space in any + field and pick response() to pull it out with a JSONPath + + ); +} diff --git a/apps/yaak-client/components/hints/SecretVariableHint.tsx b/apps/yaak-client/components/hints/SecretVariableHint.tsx new file mode 100644 index 000000000..4652272e5 --- /dev/null +++ b/apps/yaak-client/components/hints/SecretVariableHint.tsx @@ -0,0 +1,44 @@ +import { useEnvironmentsBreakdown } from "../../hooks/useEnvironmentsBreakdown"; +import { + addVariableToBaseEnvironment, + isTemplate, + variableTemplate, +} from "../../lib/addVariableToBaseEnvironment"; +import { dismissFeatureHint, FeatureHint } from "../core/FeatureHint"; + +const HINT_ID = "secret-variable"; +const DOCS_URL = "https://yaak.app/docs/templating/environments-and-variables"; + +interface Props { + /** Becomes the variable name, so it should describe the value (eg. "password", "token") */ + name: string; + value: string; + onReplace: (template: string) => void; +} + +/** + * A literal secret typed straight into an auth field. Offer to move it to a variable so the + * request references it instead of holding it. + */ +export function SecretVariableHint({ name, value, onReplace }: Props) { + const { baseEnvironment } = useEnvironmentsBreakdown(); + if (value.trim() === "" || isTemplate(value) || baseEnvironment == null) return null; + + return ( + { + const finalName = await addVariableToBaseEnvironment(baseEnvironment, name, value); + onReplace(variableTemplate(finalName)); + await dismissFeatureHint(HINT_ID); + }, + }} + > + Typing this in by hand? Store it in a variable to reuse it across requests and swap it per + environment. + + ); +} diff --git a/apps/yaak-client/components/hints/SharedOriginHint.tsx b/apps/yaak-client/components/hints/SharedOriginHint.tsx new file mode 100644 index 000000000..a54f61252 --- /dev/null +++ b/apps/yaak-client/components/hints/SharedOriginHint.tsx @@ -0,0 +1,73 @@ +import { httpRequestsAtom, patchModel } from "@yaakapp-internal/models"; +import { InlineCode } from "@yaakapp-internal/ui"; +import { useAtomValue } from "jotai"; +import { useMemo } from "react"; +import { useEnvironmentsBreakdown } from "../../hooks/useEnvironmentsBreakdown"; +import { + addVariableToBaseEnvironment, + isTemplate, + variableTemplate, +} from "../../lib/addVariableToBaseEnvironment"; +import { FeatureHint } from "../core/FeatureHint"; + +const MIN_SHARED_REQUESTS = 3; +const DOCS_URL = "https://yaak.app/docs/templating/environments-and-variables"; + +/** + * Once a few requests spell out the same literal origin, offer to hoist it into a variable and + * rewrite them all at once. + */ +export function SharedOriginHint() { + const requests = useAtomValue(httpRequestsAtom); + const { baseEnvironment } = useEnvironmentsBreakdown(); + + const shared = useMemo(() => { + const byOrigin = new Map(); + for (const r of requests) { + if (isTemplate(r.url)) continue; + const origin = literalOrigin(r.url); + if (origin == null) continue; + byOrigin.set(origin, [...(byOrigin.get(origin) ?? []), r]); + } + let best: { origin: string; requests: typeof requests } | null = null; + for (const [origin, group] of byOrigin) { + if (group.length >= MIN_SHARED_REQUESTS && group.length > (best?.requests.length ?? 0)) { + best = { origin, requests: group }; + } + } + return best; + }, [requests]); + + if (shared == null || baseEnvironment == null) return null; + + const { origin } = shared; + const count = shared.requests.length; + + return ( + { + const name = await addVariableToBaseEnvironment(baseEnvironment, "base_url", origin); + const template = variableTemplate(name); + await Promise.all( + shared.requests.map((r) => + patchModel(r, { url: template + r.url.slice(origin.length) }), + ), + ); + }, + }} + > + {count} requests start with {origin}. Put it in a variable and switch + hosts by switching environments. + + ); +} + +function literalOrigin(url: string): string | null { + const m = /^(https?:\/\/[^/?#\s]+)/i.exec(url.trim()); + return m?.[1] ?? null; +} diff --git a/apps/yaak-client/components/hints/SyncWorkspaceHint.tsx b/apps/yaak-client/components/hints/SyncWorkspaceHint.tsx new file mode 100644 index 000000000..1b9e0bb45 --- /dev/null +++ b/apps/yaak-client/components/hints/SyncWorkspaceHint.tsx @@ -0,0 +1,44 @@ +import { VStack } from "@yaakapp-internal/ui"; +import { openWorkspaceSettings } from "../../commands/openWorkspaceSettings"; +import { useKeyValue } from "../../hooks/useKeyValue"; +import { showToast } from "../../lib/toast"; +import { FeatureHint } from "../core/FeatureHint"; + +const DOCS_URL = "https://yaak.app/docs/collaboration/local-directory-git-sync"; + +/** What the sidebar's Git slot shows while the workspace only lives in the app's database. */ +export function SyncWorkspaceHint({ workspaceId }: { workspaceId: string }) { + // Hidden from the menu this replaced, so honor it + const { value: legacyHidden } = useKeyValue>({ + key: "setup_sync", + fallback: {}, + }); + + if (legacyHidden == null || legacyHidden[workspaceId]) return null; + + return ( + openWorkspaceSettings("settings", "sync_dir") }} + onDismiss={showSyncLocationToast} + > + Sync this workspace to a folder of plain files to back it up or track it with Git. + + ); +} + +function showSyncLocationToast() { + showToast({ + id: "sync-hint-dismissed", + color: "info", + timeout: 8000, + message: ( + +

Sync whenever you're ready

+

Directory sync and Git are in Workspace Settings

+
+ ), + }); +} diff --git a/apps/yaak-client/lib/addVariableToBaseEnvironment.ts b/apps/yaak-client/lib/addVariableToBaseEnvironment.ts new file mode 100644 index 000000000..3879671cc --- /dev/null +++ b/apps/yaak-client/lib/addVariableToBaseEnvironment.ts @@ -0,0 +1,31 @@ +import type { Environment } from "@yaakapp-internal/models"; +import { patchModel } from "@yaakapp-internal/models"; +import { generateId } from "./generateId"; + +/** Adds a variable, suffixing the name if it's taken, and returns the name that was used. */ +export async function addVariableToBaseEnvironment( + environment: Environment, + name: string, + value: string, +): Promise { + const taken = new Set(environment.variables.map((v) => v.name)); + let finalName = name; + for (let i = 2; taken.has(finalName); i++) { + finalName = `${name}_${i}`; + } + await patchModel(environment, { + variables: [ + ...environment.variables, + { id: generateId(), name: finalName, value, enabled: true }, + ], + }); + return finalName; +} + +export function variableTemplate(name: string) { + return `\${[ ${name} ]}`; +} + +export function isTemplate(value: string) { + return value.includes("${["); +} diff --git a/packages/tailwind-config/index.css b/packages/tailwind-config/index.css index 20163ecf0..8e311aa1a 100644 --- a/packages/tailwind-config/index.css +++ b/packages/tailwind-config/index.css @@ -57,6 +57,7 @@ --color-warning: var(--warning); --animate-blinkRing: blinkRing 150ms step-start 400ms infinite; + --animate-settingHighlight: settingHighlight 2.4s ease-out 1 both; --opacity-disabled: 30%; @@ -90,6 +91,18 @@ --transition-property-grid: grid; + @keyframes settingHighlight { + 0%, + 50% { + background-color: color-mix(in srgb, var(--primary) 9%, transparent); + box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent); + } + 100% { + background-color: transparent; + box-shadow: inset 0 0 0 1px transparent; + } + } + @keyframes blinkRing { 0%, 49% { diff --git a/packages/theme/src/window.ts b/packages/theme/src/window.ts index 485eb840f..0f46f813a 100644 --- a/packages/theme/src/window.ts +++ b/packages/theme/src/window.ts @@ -175,8 +175,11 @@ function bannerColorVariables(theme: Theme, color: YaakColor): CSSVariables { textSubtle: color.desaturate(0.58).lift(0.04).translucify(0.04).css(), textSubtlest: color.desaturate(0.65).translucify(0.18).css(), surface: color.translucify(0.95).css(), - surfaceHighlight: color.translucify(0.85).css(), + surfaceHighlight: color.translucify(0.9).css(), border: color.lift(0.3).translucify(0.8).css(), + // Left unset, this is derived from the surface at full opacity, which outlines inline code + // in a saturated color that belongs to nothing else in the banner + borderSubtle: color.lift(0.3).translucify(0.86).css(), }); }