Skip to content

Commit 21fb59d

Browse files
improvment: expose auto output flag (#5652)
## 📝 Summary Followup to #5647 <img width="614" height="166" alt="image" src="https://github.com/user-attachments/assets/ff053c5b-b70f-4f9f-ba46-a683977d301a" /> Adds options for auto download to UI --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b38be3f commit 21fb59d

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

frontend/src/components/app-config/user-config-form.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { saveUserConfig } from "@/core/network/requests";
4444
import { isWasm } from "@/core/wasm/utils";
4545
import { Banner } from "@/plugins/impl/common/error-banner";
4646
import { THEMES } from "@/theme/useTheme";
47+
import { arrayToggle } from "@/utils/arrays";
4748
import { cn } from "@/utils/cn";
4849
import { keyboardShortcutsAtom } from "../editor/controls/keyboard-shortcuts";
4950
import { Badge } from "../ui/badge";
@@ -975,6 +976,66 @@ export const UserConfigForm: React.FC = () => {
975976
</div>
976977
)}
977978
/>
979+
<FormField
980+
control={form.control}
981+
name="runtime.default_auto_download"
982+
render={({ field }) => (
983+
<div className="flex flex-col gap-y-1">
984+
<FormItem className={formItemClasses}>
985+
<FormLabel>Auto output formats</FormLabel>
986+
<FormControl>
987+
<div className="flex gap-4">
988+
<div className="flex items-center space-x-2">
989+
<Checkbox
990+
id="html-checkbox"
991+
checked={
992+
Array.isArray(field.value) &&
993+
field.value.includes("html")
994+
}
995+
onCheckedChange={() => {
996+
const currentValue = Array.isArray(field.value)
997+
? field.value
998+
: [];
999+
field.onChange(arrayToggle(currentValue, "html"));
1000+
}}
1001+
/>
1002+
<FormLabel htmlFor="html-checkbox">HTML</FormLabel>
1003+
</div>
1004+
<div className="flex items-center space-x-2">
1005+
<Checkbox
1006+
id="ipynb-checkbox"
1007+
checked={
1008+
Array.isArray(field.value) &&
1009+
field.value.includes("ipynb")
1010+
}
1011+
onCheckedChange={() => {
1012+
const currentValue = Array.isArray(field.value)
1013+
? field.value
1014+
: [];
1015+
field.onChange(
1016+
arrayToggle(currentValue, "ipynb"),
1017+
);
1018+
}}
1019+
/>
1020+
<FormLabel htmlFor="ipynb-checkbox">IPYNB</FormLabel>
1021+
</div>
1022+
</div>
1023+
</FormControl>
1024+
<FormMessage />
1025+
<IsOverridden
1026+
userConfig={config}
1027+
name="runtime.default_auto_download"
1028+
/>
1029+
</FormItem>
1030+
<FormDescription>
1031+
When enabled, marimo will periodically save notebooks in
1032+
your selected formats (HTML, IPYNB) to a folder named{" "}
1033+
<Kbd className="inline">__marimo__</Kbd> next to your
1034+
notebook file.
1035+
</FormDescription>
1036+
</div>
1037+
)}
1038+
/>
9781039
<FormField
9791040
control={form.control}
9801041
name="runtime.auto_instantiate"

frontend/src/core/config/__tests__/config-schema.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ test("default UserConfig - empty", () => {
7575
"runtime": {
7676
"auto_instantiate": true,
7777
"auto_reload": "off",
78+
"default_auto_download": [],
7879
"default_sql_output": "auto",
7980
"on_cell_change": "autorun",
8081
"watcher_on_save": "lazy",
@@ -133,6 +134,7 @@ test("default UserConfig - one level", () => {
133134
"runtime": {
134135
"auto_instantiate": true,
135136
"auto_reload": "off",
137+
"default_auto_download": [],
136138
"default_sql_output": "auto",
137139
"on_cell_change": "autorun",
138140
"watcher_on_save": "lazy",

frontend/src/core/config/config-schema.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const VALID_SQL_OUTPUT_FORMATS = [
3737
] as const;
3838
export type SqlOutputType = (typeof VALID_SQL_OUTPUT_FORMATS)[number];
3939

40+
/**
41+
* Export types for auto download
42+
*/
43+
const AUTO_DOWNLOAD_FORMATS = ["html", "markdown", "ipynb"] as const;
44+
4045
export const UserConfigSchema = z
4146
.object({
4247
completion: z
@@ -92,6 +97,9 @@ export const UserConfigSchema = z
9297
auto_reload: z.enum(["off", "lazy", "autorun"]).default("off"),
9398
watcher_on_save: z.enum(["lazy", "autorun"]).default("lazy"),
9499
default_sql_output: z.enum(VALID_SQL_OUTPUT_FORMATS).default("auto"),
100+
default_auto_download: z
101+
.array(z.enum(AUTO_DOWNLOAD_FORMATS))
102+
.default([]),
95103
})
96104
.passthrough()
97105
.default({}),
@@ -214,7 +222,7 @@ export const AppConfigSchema = z
214222
app_title: AppTitleSchema.nullish(),
215223
css_file: z.string().nullish(),
216224
html_head_file: z.string().nullish(),
217-
auto_download: z.array(z.enum(["html", "markdown", "ipynb"])).default([]),
225+
auto_download: z.array(z.enum(AUTO_DOWNLOAD_FORMATS)).default([]),
218226
sql_output: SqlOutputSchema,
219227
})
220228
.default({ width: "medium", auto_download: [] });

0 commit comments

Comments
 (0)