Skip to content

Commit 1b2a447

Browse files
samejrericallam
authored andcommitted
Improvements to the Preview tab
1 parent 872a4e5 commit 1b2a447

1 file changed

Lines changed: 25 additions & 28 deletions

File tree

  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.prompts.$promptSlug

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.prompts.$promptSlug/route.tsx

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,6 @@ function PreviewTab({
10371037
content: string;
10381038
}) {
10391039
const variableFields = prompt.variableSchema ? extractVariableFields(prompt.variableSchema) : [];
1040-
10411040
const [testVariables, setTestVariables] = useState<Record<string, string>>(() =>
10421041
Object.fromEntries(variableFields.map((f) => [f.name, ""]))
10431042
);
@@ -1049,14 +1048,20 @@ function PreviewTab({
10491048
{variableFields.length > 0 ? (
10501049
<>
10511050
<div className="space-y-3">
1052-
<Header3>Variables</Header3>
1053-
{variableFields.map((field) => (
1054-
<InputGroup key={field.name}>
1051+
<div>
1052+
<Header3 className="mb-1">Variables</Header3>
1053+
<Paragraph variant="small">
1054+
Fill in values to preview your resolved prompt template.
1055+
</Paragraph>
1056+
</div>
1057+
{variableFields.map((field, index) => (
1058+
<InputGroup className="max-w-full" key={field.name}>
10551059
<Label variant="small" required={field.required}>
10561060
{field.name}
10571061
</Label>
10581062
{field.enumValues ? (
10591063
<select
1064+
autoFocus={index === 0}
10601065
className="h-6 w-full rounded border border-charcoal-650 bg-background-bright px-1 text-xs text-text-bright focus:border-indigo-500 focus:outline-none"
10611066
value={testVariables[field.name] ?? ""}
10621067
onChange={(e) =>
@@ -1066,7 +1071,7 @@ function PreviewTab({
10661071
}))
10671072
}
10681073
>
1069-
<option value="">Select...</option>
1074+
<option value="">Select</option>
10701075
{field.enumValues.map((v) => (
10711076
<option key={v} value={v}>
10721077
{v}
@@ -1075,8 +1080,9 @@ function PreviewTab({
10751080
</select>
10761081
) : field.isLongText ? (
10771082
<TextArea
1083+
autoFocus={index === 0}
10781084
rows={3}
1079-
className="text-xs"
1085+
className="w-full text-sm"
10801086
placeholder={field.placeholder}
10811087
value={testVariables[field.name] ?? ""}
10821088
onChange={(e) =>
@@ -1088,6 +1094,7 @@ function PreviewTab({
10881094
/>
10891095
) : (
10901096
<Input
1097+
autoFocus={index === 0}
10911098
variant="small"
10921099
placeholder={field.placeholder}
10931100
value={testVariables[field.name] ?? ""}
@@ -1104,38 +1111,28 @@ function PreviewTab({
11041111
))}
11051112
</div>
11061113

1107-
<div className="space-y-1">
1108-
<Header3>Resolved output</Header3>
1109-
{previewText ? (
1110-
<div className="overflow-auto rounded border border-indigo-500/30 bg-charcoal-900 p-3">
1114+
{previewText && (
1115+
<div className="space-y-1.5">
1116+
<Header3>Resolved output</Header3>
1117+
<div className="overflow-auto rounded border border-grid-bright bg-background-dimmed p-3">
11111118
<pre className="whitespace-pre-wrap font-mono text-sm leading-relaxed text-text-bright">
11121119
{previewText}
11131120
</pre>
11141121
</div>
1115-
) : (
1116-
<div className="rounded border border-grid-dimmed bg-charcoal-900/50 p-3">
1117-
<Paragraph variant="extra-small" className="text-charcoal-500">
1118-
Fill in variables to see the resolved prompt
1119-
</Paragraph>
1120-
</div>
1121-
)}
1122-
</div>
1122+
</div>
1123+
)}
11231124
</>
11241125
) : (
1125-
<div className="space-y-1">
1126-
<Header3>Resolved output</Header3>
1127-
{content ? (
1128-
<div className="overflow-auto rounded border border-grid-dimmed bg-charcoal-900 p-3">
1126+
content && (
1127+
<>
1128+
<Header3>Resolved output</Header3>
1129+
<div className="overflow-auto rounded border border-grid-bright bg-background-dimmed p-3">
11291130
<pre className="whitespace-pre-wrap font-mono text-sm leading-relaxed text-text-bright">
11301131
{content}
11311132
</pre>
11321133
</div>
1133-
) : (
1134-
<Paragraph variant="small" className="text-charcoal-500">
1135-
No content to preview
1136-
</Paragraph>
1137-
)}
1138-
</div>
1134+
</>
1135+
)
11391136
)}
11401137
</div>
11411138
);

0 commit comments

Comments
 (0)