Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(frontend): enhance secret diff components and commit handling
Victor Santos490d8c7d1f86
diff --git a/backend/src/ee/services/pit/pit-service.ts b/backend/src/ee/services/pit/pit-service.tsindex 9922ad6e5f..a8d3e0afa3 100644--- a/backend/src/ee/services/pit/pit-service.ts+++ b/backend/src/ee/services/pit/pit-service.ts@@ -680,6 +680,27 @@ export const pitServiceFactory = ({}if (policy) {+ // When a policy exists, secret changes go through approval workflow+ // but folder changes should still be committed immediately since they're not affected by approval policies+ let commitId: string | undefined;+ if (commitChanges.length > 0) {+ const commit = await folderCommitService.createCommit(+ {+ actor: {+ type: actor || ActorType.PLATFORM,+ metadata: {+ id: actorId+ }+ },+ message,+ folderId: targetFolder.id,+ changes: commitChanges+ },+ trx+ );+ commitId = commit?.id;+ }+if ((changes.secrets?.create?.length ?? 0) > 0 ||(changes.secrets?.update?.length ?? 0) > 0 ||@@ -724,11 +745,13 @@ export const pitServiceFactory = ({});return {approvalId: approval.id,+ commitId,folderChanges,secretMutationEvents};}return {+ commitId,folderChanges,secretMutationEvents};diff --git a/frontend/src/components/secrets/diff/DiffContainer.tsx b/frontend/src/components/secrets/diff/DiffContainer.tsxindex a8e1ca2d8f..5cbed0e65f 100644--- a/frontend/src/components/secrets/diff/DiffContainer.tsx+++ b/frontend/src/components/secrets/diff/DiffContainer.tsx@@ -53,7 +53,7 @@ export const DiffContainer = ({)}style={{ backgroundColor }}>- <div className="min-w-max">{children}</div>+ <div className="w-max min-w-full">{children}</div></div>);};diff --git a/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx b/frontend/src/components/secrets/diff/FieldDiffRenderers.tsxindex 583119bc5a..cd5baa7ce7 100644--- a/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx+++ b/frontend/src/components/secrets/diff/FieldDiffRenderers.tsx@@ -165,13 +165,13 @@ export const MetadataDiffRenderer = ({"bg-mineshaft-500",keyHighlighted &&(isOldVersion- ? "ring-1 ring-red-500/60 ring-inset"- : "ring-1 ring-green-500/60 ring-inset")+ ? "bg-red-500/30 ring-1 ring-red-500/60 ring-inset"+ : "bg-green-500/30 ring-1 ring-green-500/60 ring-inset"));// Value: color background if changedconst valueBgClass = twMerge(- valueHighlighted && (isOldVersion ? "bg-red-600/30" : "bg-green-600/30"),+ valueHighlighted && (isOldVersion ? "bg-red-900/30" : "bg-green-900/30"),!valueHighlighted && "bg-mineshaft-900");diff --git a/frontend/src/components/secrets/diff/MultiLineDiff.tsx b/frontend/src/components/secrets/diff/MultiLineDiff.tsxindex e8d8b3ffbc..1371782043 100644--- a/frontend/src/components/secrets/diff/MultiLineDiff.tsx+++ b/frontend/src/components/secrets/diff/MultiLineDiff.tsx@@ -1,8 +1,6 @@-import {- computeLineDiff,- computeWordDiff,- splitChangeIntoLines-} from "@app/components/utilities/diff";+import { computeLineDiff, splitChangeIntoLines } from "@app/components/utilities/diff";++import { renderTextDiff } from "./SingleLineDiff";export interface MultiLineDiffProps {oldText: string;@@ -10,17 +8,20 @@ export interface MultiLineDiffProps {isOldVersion: boolean;}+// Color classes for multiline diff (slightly different opacity for line context)+const ADDED_CLASS = "rounded bg-green-500/60 px-0.5";+const REMOVED_CLASS = "rounded bg-red-500/60 px-0.5";+/*** Render multiline diff for approval screen (side-by-side view)*/export const MultiLineDiff = ({ oldText, newText, isOldVersion }: MultiLineDiffProps) => {const lineChanges = computeLineDiff(oldText, newText);- // Check if this is just an append/prepend operation where old content is preserved- // If the new text starts with or ends with the old text, the old content wasn't removed- const isAppendOnly = oldText !== "" && newText.startsWith(oldText);- const isPrependOnly = oldText !== "" && newText.endsWith(oldText);- const isOldPreserved = isAppendOnly || isPrependOnly;+ // Check if old text is contained within new text (pure insertion at text level)+ const oldExistsInNew = oldText !== "" && newText !== "" && newText.includes(oldText);+ // Check if new text is contained within old text (pure deletion at text level)+ const newExistsInOld = oldText !== "" && newText !== "" && oldText.includes(newText);// Find the first changed line indexlet firstChangedIndex = -1;@@ -41,9 +42,10 @@ export const MultiLineDiff = ({ oldText, newText, isOldVersion }: MultiLineDiffPlet firstChangedFound = false;return (- <div className="min-w-full font-mono text-sm break-words whitespace-pre-wrap">+ <div className="w-max min-w-full font-mono text-sm whitespace-pre">{lineChanges.map((change, changeIdx) => {const nextChange = lineChanges[changeIdx + 1];+ const prevChange = changeIdx > 0 ? lineChanges[changeIdx - 1] : undefined;const lines = splitChangeIntoLines(change.value);return lines.map((line, lineIdx) => {@@ -52,108 +54,42 @@ export const MultiLineDiff = ({ oldText, newText, isOldVersion }: MultiLineDiffPif (isFirstChanged) firstChangedFound = true;currentLineIndex += 1;- if (isOldVersion) {- // Render old version- if (change.added) {- return null; // Skip added lines in old version- }-- // If old content is preserved (append/prepend only), don't highlight old lines- // even if diffLines marks them as "removed"- const isActuallyChanged = change.removed && !isOldPreserved;- const lineClass = isActuallyChanged- ? "flex min-w-full bg-red-500/70 rounded-xs text-red-300"- : "flex min-w-full";-- // If this is a removed line followed by an added line, it's a modification- // But only show word-level diff if old content wasn't fully preserved- if (change.removed && nextChange?.added && !isOldPreserved) {- const nextLines = splitChangeIntoLines(nextChange.value);- const newLine = nextLines[lineIdx] ?? "";- const wordDiffs = computeWordDiff(line, newLine);-- // If no common words, just show the line with line-level background- if (wordDiffs === null) {- return (- <div- key={lineKey}- className={lineClass}- data-first-change={isFirstChanged ? "true" : undefined}- >- <div className="w-4 shrink-0">-</div>- <div className="min-w-0 flex-1 break-words">{line}</div>- </div>- );- }-- return (- <div- key={lineKey}- className={lineClass}- data-first-change={isFirstChanged ? "true" : undefined}- >- <div className="w-4 shrink-0">-</div>- <div className="min-w-0 flex-1 break-words">- {wordDiffs.map((wordChange, wordIdx) => {- if (wordChange.added) return null;- const wordKey = `${lineKey}-word-${wordIdx}`;- const wordClass = wordChange.removed ? "bg-red-600/70 rounded px-0.5" : "";- return (- <span key={wordKey} className={wordClass}>- {wordChange.value}- </span>- );- })}- </div>- </div>- );- }-- return (- <div- key={lineKey}- className={lineClass}- data-first-change={isFirstChanged ? "true" : undefined}- >- <div className="w-4 shrink-0">{isActuallyChanged ? "-" : " "}</div>- <div className="min-w-0 flex-1 break-words">{line}</div>- </div>- );+ // Skip opposite change type (added lines in old version, removed lines in new version)+ const isSkipped = isOldVersion ? change.added : change.removed;+ if (isSkipped) {+ return null;}- // Render new version- if (change.removed) {- return null; // Skip deleted lines in new version- }+ // Determine if this line represents a modification (removed followed by added or vice versa)+ const adjacentChange = isOldVersion ? nextChange : prevChange;+ const isModification = isOldVersion+ ? change.removed && nextChange?.added+ : prevChange?.removed && change.added;- // Check if previous change was removed (modification case)- const prevChange = changeIdx > 0 ? lineChanges[changeIdx - 1] : undefined;- const isModification = prevChange?.removed && change.added;+ // Determine if this line should be highlighted as changed+ // For modifications, always highlight. For pure add/remove, check whole-text containment.+ const isChanged =+ isModification ||+ (isOldVersion ? change.removed && !oldExistsInNew : change.added && !newExistsInOld);- const isChanged = change.added;const lineClass = isChanged- ? "flex min-w-full bg-[#2ecc71]/40 rounded-xs text-green-300"+ ? `flex min-w-full rounded-xs ${+ isOldVersion ? "bg-red-500/30 text-red-300" : "bg-green-500/30 text-green-300"+ }`: "flex min-w-full";- // If this is a modification, show word-level diff- if (isModification && prevChange) {- const prevLines = splitChangeIntoLines(prevChange.value);- const oldLine = prevLines[lineIdx] ?? "";- const wordDiffs = computeWordDiff(oldLine, line);-- // If no common words, just show the line with line-level background- if (wordDiffs === null) {- return (- <div- key={lineKey}- className={lineClass}- data-first-change={isFirstChanged ? "true" : undefined}- >- <div className="w-4 shrink-0">+</div>- <div className="min-w-0 flex-1 break-words">{line}</div>- </div>- );- }+ let symbol = " ";+ if (isChanged) {+ symbol = isOldVersion ? "-" : "+";+ }++ // Handle modification with word-level diff+ if (isModification && adjacentChange) {+ const adjacentLines = splitChangeIntoLines(adjacentChange.value);+ const adjacentLine = adjacentLines[lineIdx] ?? "";+ const [diffOldText, diffNewText] = isOldVersion+ ? [line, adjacentLine]+ : [adjacentLine, line];return (<div@@ -161,31 +97,30 @@ export const MultiLineDiff = ({ oldText, newText, isOldVersion }: MultiLineDiffPclassName={lineClass}data-first-change={isFirstChanged ? "true" : undefined}>- <div className="w-4 shrink-0">+</div>- <div className="min-w-0 flex-1 break-words">- {wordDiffs.map((wordChange, wordIdx) => {- if (wordChange.removed) return null;- const wordKey = `${lineKey}-word-${wordIdx}`;- const wordClass = wordChange.added ? "bg-[#2ecc71]/60 rounded px-0.5" : "";- return (- <span key={wordKey} className={wordClass}>- {wordChange.value}- </span>- );+ <div className="w-4 shrink-0">{symbol}</div>+ <div className="flex-1">+ {renderTextDiff({+ oldText: diffOldText,+ newText: diffNewText,+ isOldVersion,+ keyPrefix: lineKey,+ addedClass: ADDED_CLASS,+ removedClass: REMOVED_CLASS})}</div></div>);}+ // Plain line renderingreturn (<divkey={lineKey}className={lineClass}data-first-change={isFirstChanged ? "true" : undefined}>- <div className="w-4 shrink-0">{isChanged ? "+" : " "}</div>- <div className="min-w-0 flex-1 break-words">{line}</div>+ <div className="w-4 shrink-0">{symbol}</div>+ <div className="flex-1">{line}</div></div>);});diff --git a/frontend/src/components/secrets/diff/SecretDiffView.tsx b/frontend/src/components/secrets/diff/SecretDiffView.tsxindex 2b89ca85c9..ee795211c1 100644--- a/frontend/src/components/secrets/diff/SecretDiffView.tsx+++ b/frontend/src/components/secrets/diff/SecretDiffView.tsx@@ -5,7 +5,7 @@ import { faCircleCheck, faCircleXmark, faEye, faEyeSlash } from "@fortawesome/frimport { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { twMerge } from "tailwind-merge";-import { areValuesEqual, isSingleLine } from "@app/components/utilities/diff";+import { isSingleLine } from "@app/components/utilities/diff";import { SecretInput, Tooltip } from "@app/components/v2";import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";@@ -32,6 +32,52 @@ export interface SecretDiffViewProps {newVersionLabel?: string;}+const CommentRenderer = ({+ comment,+ oldComment,+ newComment,+ hasChanges,+ isBothSingleLine,+ isOldVersion,+ containerRef+}: {+ comment: string;+ oldComment: string;+ newComment: string;+ hasChanges: boolean;+ isBothSingleLine: boolean;+ isOldVersion: boolean;+ containerRef: React.RefObject<HTMLDivElement>;+}) => {+ if (!comment) {+ return <span className="text-sm text-mineshaft-300">-</span>;+ }++ if (!hasChanges) {+ return (+ <div className="max-h-32 thin-scrollbar overflow-y-auto rounded border border-mineshaft-600 bg-bunker-800 p-2">+ <span className="text-sm whitespace-pre-wrap">{comment}</span>+ </div>+ );+ }++ const variant = isOldVersion ? "removed" : "added";++ if (isBothSingleLine) {+ return (+ <DiffContainer variant={variant} isSingleLine>+ <SingleLineDiff oldText={oldComment} newText={newComment} isOldVersion={isOldVersion} />+ </DiffContainer>+ );+ }++ return (+ <DiffContainer variant={variant} containerRef={containerRef}>+ <MultiLineDiff oldText={oldComment} newText={newComment} isOldVersion={isOldVersion} />+ </DiffContainer>+ );+};+const SecretValueRenderer = ({isOldVersion,isValueHidden,@@ -97,19 +143,25 @@ const SecretValueRenderer = ({<SecretInputisReadOnlyisVisible={isVisible}- valueAlwaysHidden={isValueHidden}- value={value}+ valueAlwaysHidden={isValueHidden || !isVisible}+ value={value ?? HIDDEN_SECRET_VALUE}containerClassName={twMerge("border border-mineshaft-600 bg-bunker-700 py-1.5 text-bunker-300 hover:border-primary-400/50",isValueHidden ? "pr-2 pl-8" : "px-2")}/>- <div className="absolute top-1 right-1" onClick={() => setIsVisible(!isVisible)}>- <FontAwesomeIcon- icon={isVisible ? faEyeSlash : faEye}- className="cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-800 p-1.5 text-mineshaft-300 hover:bg-mineshaft-700"- />- </div>+ {value && (+ <div className="absolute top-1 right-1">+ <FontAwesomeIcon+ icon={isVisible ? faEyeSlash : faEye}+ className="cursor-pointer rounded-md border border-mineshaft-500 bg-mineshaft-800 p-1.5 text-mineshaft-300 hover:bg-mineshaft-700"+ onClick={(e) => {+ e.stopPropagation();+ setIsVisible(!isVisible);+ }}+ />+ </div>+ )}</div>);};@@ -123,10 +175,12 @@ export const SecretDiffView = ({}: SecretDiffViewProps) => {const oldDiffContainerRef = useRef<HTMLDivElement>(null);const newDiffContainerRef = useRef<HTMLDivElement>(null);+ const oldCommentDiffContainerRef = useRef<HTMLDivElement>(null);+ const newCommentDiffContainerRef = useRef<HTMLDivElement>(null);const oldSecretValue = oldVersion?.secretValue ?? "";const newSecretValue = newVersion?.secretValue ?? oldVersion?.secretValue ?? "";- const hasValueChanges = !areValuesEqual(oldSecretValue, newSecretValue);+ const hasValueChanges = oldSecretValue !== newSecretValue;const isBothSingleLine = isSingleLine(oldSecretValue) && isSingleLine(newSecretValue);const oldKey = oldVersion?.secretKey ?? "";@@ -136,6 +190,7 @@ export const SecretDiffView = ({const oldComment = oldVersion?.secretComment ?? "";const newComment = newVersion?.secretComment ?? "";const hasCommentChanges = oldComment !== newComment;+ const isCommentBothSingleLine = isSingleLine(oldComment) && isSingleLine(newComment);const oldMultiline = String(oldVersion?.skipMultilineEncoding ?? false);const newMultiline = String(newVersion?.skipMultilineEncoding ?? false);@@ -150,7 +205,7 @@ export const SecretDiffView = ({return (<div className="flex flex-col space-y-4 space-x-0 xl:flex-row xl:space-y-0 xl:space-x-4">{showOldVersion ? (- <div className="flex w-full cursor-default flex-col rounded-lg border border-red-600/60 bg-red-600/10 p-4 xl:w-1/2">+ <div className="flex w-full min-w-0 cursor-default flex-col rounded-lg border border-red-600/60 bg-red-600/10 p-4 xl:w-1/2"><div className="mb-4 flex flex-row justify-between"><span className="text-md font-medium">{oldVersionLabel}</span><div className="rounded-full bg-red px-2 pt-[0.2rem] pb-[0.14rem] text-xs font-medium">@@ -182,25 +237,21 @@ export const SecretDiffView = ({</div><div className="mb-2"><div className="text-sm font-medium text-mineshaft-300">Comment</div>- {oldComment ? (- <div className="max-h-32 thin-scrollbar overflow-y-auto rounded border border-mineshaft-600 bg-bunker-800 p-2">- <InlineTextDiff- oldText={oldComment}- newText={newComment}- isOldVersion- hasChanges={hasCommentChanges}- preserveWhitespace- />- </div>- ) : (- <span className="text-sm text-mineshaft-300">-</span>- )}+ <CommentRenderer+ comment={oldComment}+ oldComment={oldComment}+ newComment={newComment}+ hasChanges={hasCommentChanges}+ isBothSingleLine={isCommentBothSingleLine}+ isOldVersion+ containerRef={oldCommentDiffContainerRef}+ /></div><div className="mb-2"><div className="text-sm font-medium text-mineshaft-300">Tags</div><TagsDiffRenderer- tags={oldTags.map((tag) => ({ slug: tag.slug, color: tag.color }))}- otherTags={newTags.map((tag) => ({ slug: tag.slug, color: tag.color }))}+ tags={oldTags.map((tag) => ({ slug: tag.slug, color: tag.color ?? "" }))}+ otherTags={newTags.map((tag) => ({ slug: tag.slug, color: tag.color ?? "" }))}isOldVersion/></div>@@ -232,7 +283,7 @@ export const SecretDiffView = ({)}{showNewVersion ? (- <div className="flex w-full cursor-default flex-col rounded-lg border border-green-600/60 bg-green-600/10 p-4 xl:w-1/2">+ <div className="flex w-full min-w-0 cursor-default flex-col rounded-lg border border-green-600/60 bg-green-600/10 p-4 xl:w-1/2"><div className="mb-4 flex flex-row justify-between"><span className="text-md font-medium">{newVersionLabel}</span><div className="rounded-full bg-green-600 px-2 pt-[0.2rem] pb-[0.14rem] text-xs font-medium">@@ -264,25 +315,21 @@ export const SecretDiffView = ({</div><div className="mb-2"><div className="text-sm font-medium text-mineshaft-300">Comment</div>- {newComment ? (- <div className="max-h-32 thin-scrollbar overflow-y-auto rounded border border-mineshaft-600 bg-bunker-800 p-2">- <InlineTextDiff- oldText={oldComment}- newText={newComment}- isOldVersion={false}- hasChanges={hasCommentChanges}- preserveWhitespace- />- </div>- ) : (- <span className="text-sm text-mineshaft-300">-</span>- )}+ <CommentRenderer+ comment={newComment}+ oldComment={oldComment}+ newComment={newComment}+ hasChanges={hasCommentChanges}+ isBothSingleLine={isCommentBothSingleLine}+ isOldVersion={false}+ containerRef={newCommentDiffContainerRef}+ /></div><div className="mb-2"><div className="text-sm font-medium text-mineshaft-300">Tags</div><TagsDiffRenderer- tags={newTags.map((tag) => ({ slug: tag.slug, color: tag.color }))}- otherTags={oldTags.map((tag) => ({ slug: tag.slug, color: tag.color }))}+ tags={newTags.map((tag) => ({ slug: tag.slug, color: tag.color ?? "" }))}+ otherTags={oldTags.map((tag) => ({ slug: tag.slug, color: tag.color ?? "" }))}isOldVersion={false}/></div>diff --git a/frontend/src/components/secrets/diff/SingleLineDiff.tsx b/frontend/src/components/secrets/diff/SingleLineDiff.tsxindex e373cbdf5d..586798c376 100644--- a/frontend/src/components/secrets/diff/SingleLineDiff.tsx+++ b/frontend/src/components/secrets/diff/SingleLineDiff.tsx@@ -1,5 +1,3 @@-import { diffChars } from "diff";-import { computeWordDiff } from "@app/components/utilities/diff";export interface SingleLineDiffProps {@@ -8,151 +6,95 @@ export interface SingleLineDiffProps {isOldVersion: boolean;}+export interface RenderTextDiffOptions {+ oldText: string;+ newText: string;+ isOldVersion: boolean;+ keyPrefix?: string;+ addedClass?: string;+ removedClass?: string;+}+/**- * Render single-line diff (just word highlighting, no container/+/-)+ * Renders text with highlighted prefix and/or suffix around unchanged content.*/-export const SingleLineDiff = ({ oldText, newText, isOldVersion }: SingleLineDiffProps) => {- // Check if old text is contained within new text (pure insertion - append, prepend, or middle)+const renderWithHighlightedParts = (+ unchangedText: string,+ prefixText: string,+ suffixText: string,+ highlightClass: string+): React.ReactNode => {+ return (+ <>+ {prefixText && <span className={highlightClass}>{prefixText}</span>}+ <span>{unchangedText}</span>+ {suffixText && <span className={highlightClass}>{suffixText}</span>}+ </>+ );+};++/**+ * Core diff rendering logic - returns React nodes for text diff highlighting.+ * Handles pure insertions, pure deletions, and mixed changes.+ * Can be used standalone or wrapped in a container component.+ */+export const renderTextDiff = ({+ oldText,+ newText,+ isOldVersion,+ keyPrefix = "diff",+ addedClass = "rounded bg-green-600/70 px-0.5",+ removedClass = "rounded bg-red-600/70 px-0.5"+}: RenderTextDiffOptions): React.ReactNode => {+ // Check if one text contains the other (pure insertion or deletion)const oldExistsInNew = oldText !== "" && newText !== "" && newText.includes(oldText);+ const newExistsInOld = oldText !== "" && newText !== "" && oldText.includes(newText);+ // Pure insertion: old text is fully contained in new textif (oldExistsInNew) {- const startIndex = newText.indexOf(oldText);- const endIndex = startIndex + oldText.length;-- const prependPart = newText.slice(0, startIndex);- const appendPart = newText.slice(endIndex);-if (isOldVersion) {- return (- <div className="font-mono text-sm break-words">- <span>{oldText}</span>- </div>- );+ return <span>{oldText}</span>;}-- return (- <div className="font-mono text-sm break-words">- {prependPart && <span className="rounded bg-green-600/70 px-0.5">{prependPart}</span>}- <span>{oldText}</span>- {appendPart && <span className="rounded bg-green-600/70 px-0.5">{appendPart}</span>}- </div>- );+ const startIndex = newText.indexOf(oldText);+ const prependPart = newText.slice(0, startIndex);+ const appendPart = newText.slice(startIndex + oldText.length);+ return renderWithHighlightedParts(oldText, prependPart, appendPart, addedClass);}- // Check if new text is contained within old text (pure deletion)- const newExistsInOld = oldText !== "" && newText !== "" && oldText.includes(newText);-+ // Pure deletion: new text is fully contained in old textif (newExistsInOld) {- const startIndex = oldText.indexOf(newText);- const endIndex = startIndex + newText.length;-- const removedPrefix = oldText.slice(0, startIndex);- const removedSuffix = oldText.slice(endIndex);-- if (isOldVersion) {- return (- <div className="font-mono text-sm break-words">- {removedPrefix && <span className="rounded bg-red-600/70 px-0.5">{removedPrefix}</span>}- <span>{newText}</span>- {removedSuffix && <span className="rounded bg-red-600/70 px-0.5">{removedSuffix}</span>}- </div>- );- }-- return (- <div className="font-mono text-sm break-words">- <span>{newText}</span>- </div>- );- }-- // For mixed changes (both insertions and deletions), use character diff- // but only apply special handling for pure insertions- const charDiffs = diffChars(oldText, newText);- const hasRemovals = charDiffs.some((d) => d.removed);- const hasAdditions = charDiffs.some((d) => d.added);-- // Pure insertion case (no removals): don't highlight old version- if (!hasRemovals && hasAdditions) {- if (isOldVersion) {- return (- <div className="font-mono text-sm break-words">- <span>{oldText}</span>- </div>- );- }- // Show new version with character-level highlighting- return (- <div className="font-mono text-sm break-words">- {charDiffs.map((change, idx) => {- if (change.removed) return null;- const key = `char-${idx}`;- const className = change.added ? "bg-green-600/70 rounded px-0.5" : "";- return (- <span key={key} className={className}>- {change.value}- </span>- );- })}- </div>- );- }-- // Pure deletion case (no additions): don't highlight new version- if (hasRemovals && !hasAdditions) {if (!isOldVersion) {- return (- <div className="font-mono text-sm break-words">- <span>{newText}</span>- </div>- );+ return <span>{newText}</span>;}- // Show old version with character-level highlighting- return (- <div className="font-mono text-sm break-words">- {charDiffs.map((change, idx) => {- if (change.added) return null;- const key = `char-${idx}`;- const className = change.removed ? "bg-red-600/70 rounded px-0.5" : "";- return (- <span key={key} className={className}>- {change.value}- </span>- );- })}- </div>- );+ const startIndex = oldText.indexOf(newText);+ const removedPrefix = oldText.slice(0, startIndex);+ const removedSuffix = oldText.slice(startIndex + newText.length);+ return renderWithHighlightedParts(newText, removedPrefix, removedSuffix, removedClass);}- // Mixed changes: fall back to word-level diff (more readable for humans)+ // Use word-level diff for better readabilityconst wordDiffs = computeWordDiff(oldText, newText);// If no common words, show as single highlighted blockif (!wordDiffs) {const value = isOldVersion ? oldText : newText;- const highlightClass = isOldVersion- ? "bg-red-600/70 rounded px-0.5"- : "bg-green-600/70 rounded px-0.5";- return (- <div className="font-mono text-sm break-words">- <span className={highlightClass}>{value}</span>- </div>- );+ const highlightClass = isOldVersion ? removedClass : addedClass;+ return <span className={highlightClass}>{value}</span>;}// Show word-by-word diffreturn (- <div className="font-mono text-sm break-words">+ <>{wordDiffs.map((change, wordIdx) => {if (isOldVersion && change.added) return null;if (!isOldVersion && change.removed) return null;- const wordKey = `word-${wordIdx}`;+ const wordKey = `${keyPrefix}-word-${wordIdx}`;let wordClass = "";if (change.removed) {- wordClass = "bg-red-600/70 rounded px-0.5";+ wordClass = removedClass;} else if (change.added) {- wordClass = "bg-green-600/70 rounded px-0.5";+ wordClass = addedClass;}return (@@ -161,6 +103,17 @@ export const SingleLineDiff = ({ oldText, newText, isOldVersion }: SingleLineDif</span>);})}+ </>+ );+};++/**+ * Render single-line diff with container (just word highlighting, no +/-)+ */+export const SingleLineDiff = ({ oldText, newText, isOldVersion }: SingleLineDiffProps) => {+ return (+ <div className="font-mono text-sm break-words">+ {renderTextDiff({ oldText, newText, isOldVersion })}</div>);};diff --git a/frontend/src/components/secrets/diff/index.ts b/frontend/src/components/secrets/diff/index.tsindex 196f222808..68c494784c 100644--- a/frontend/src/components/secrets/diff/index.ts+++ b/frontend/src/components/secrets/diff/index.ts@@ -5,5 +5,5 @@ export type { MultiLineDiffProps } from "./MultiLineDiff";export { MultiLineDiff } from "./MultiLineDiff";export type { SecretDiffViewProps, SecretVersionData } from "./SecretDiffView";export { SecretDiffView } from "./SecretDiffView";-export type { SingleLineDiffProps } from "./SingleLineDiff";-export { SingleLineDiff } from "./SingleLineDiff";+export type { RenderTextDiffOptions, SingleLineDiffProps } from "./SingleLineDiff";+export { renderTextDiff, SingleLineDiff } from "./SingleLineDiff";diff --git a/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx b/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsxindex d931890ee7..c0b1d0728e 100644--- a/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx+++ b/frontend/src/pages/secret-manager/CommitDetailsPage/components/SecretVersionDiffView/SecretVersionDiffView.tsx@@ -582,13 +582,13 @@ export const SecretVersionDiffView = ({if (!version) return undefined;// Handle tags - normalize to string array (slugs only)- let tags: string[] | undefined;+ let tags: { slug: string; color: string }[] | undefined;if (Array.isArray(version.tags)) {- tags = version.tags.map((tag: { slug?: string } | string) => {+ tags = version.tags.map((tag: { slug?: string; color?: string } | string) => {if (typeof tag === "string") {- return tag;+ return { slug: tag, color: "" };}- return tag.slug ?? "";+ return { slug: tag.slug ?? "", color: tag.color ?? "" };});}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsxindex aad3eb56a3..4d4dd7bb93 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/SecretDashboardPage.tsx@@ -395,8 +395,13 @@ const Page = () => {message});- if (!isProtectedBranch) {- pendingChanges.secrets.forEach((secret) => {+ // Check if there are only folder changes (no secret changes)+ // Folder changes are not affected by approval policies, so they're saved directly+ const hasOnlyFolderChanges = changes.folders.length > 0 && changes.secrets.length === 0;+ const requiresApproval = isProtectedBranch && !hasOnlyFolderChanges;++ if (!requiresApproval) {+ changes.secrets.forEach((secret) => {if (secret.type === "update" && secret.secretValue !== undefined) {queryClient.setQueryData(dashboardKeys.getSecretValue({@@ -413,7 +418,7 @@ const Page = () => {}createNotification({- text: isProtectedBranch+ text: requiresApproval? "Requested changes have been sent for review": "Changes saved successfully",type: "success"diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsxindex 0ee69146e4..4497493473 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/CommitForm/CommitForm.tsx@@ -289,6 +289,9 @@ export const CommitForm: React.FC<CommitFormProps> = ({return null;}+ const hasOnlyFolderChanges =+ pendingChanges.folders.length > 0 && pendingChanges.secrets.length === 0;+const handleCommit = async () => {await onCommit(pendingChanges, commitMessage);clearAllPendingChanges({@@ -300,6 +303,14 @@ export const CommitForm: React.FC<CommitFormProps> = ({setCommitMessage("");};+ const handleSaveChanges = async () => {+ if (hasOnlyFolderChanges) {+ await handleCommit();+ } else {+ setIsModalOpen(true);+ }+ };+return (<>{/* Floating Panel */}@@ -346,8 +357,9 @@ export const CommitForm: React.FC<CommitFormProps> = ({<Buttonvariant="solid"leftIcon={<FontAwesomeIcon icon={faSave} />}- onClick={() => setIsModalOpen(true)}- isDisabled={totalChangesCount === 0}+ onClick={handleSaveChanges}+ isDisabled={totalChangesCount === 0 || isCommitting}+ isLoading={isCommitting && hasOnlyFolderChanges}className="px-6">Save Changesdiff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsxindex 5c4e8ad506..9e1edf0f9b 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretDetailSidebar.tsx@@ -181,6 +181,7 @@ export const SecretDetailSidebar = ({resolver: zodResolver(formSchema),values: {...secret,+ tags: secret?.tags?.map((tag) => ({ id: tag.id, slug: tag.slug, tagColor: tag.color })),valueOverride: getOverrideDefaultValue(),value: getDefaultValue()},@@ -270,7 +271,7 @@ export const SecretDetailSidebar = ({tagFields.remove(tagPos);}} else {- tagFields.append(tag);+ tagFields.append({ id: tag.id, slug: tag.slug, tagColor: tag.color });}};