Skip to content

Commit f4f1ad3

Browse files
committed
feedback
1 parent 0544f28 commit f4f1ad3

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

app/web_ui/src/routes/(fullscreen)/setup/(setup)/create_task/edit_task.svelte

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848
4949
// Track initial values to detect actual changes from the loaded state.
5050
// This prevents false "unsaved changes" warnings when opening an existing task.
51-
let initial_name = task.name
52-
let initial_description = task.description
53-
let initial_instruction = task.instruction
54-
let initial_thinking_instruction = task.thinking_instruction
55-
let initial_requirements = task.requirements.map((r) => ({
56-
name: r.name,
57-
instruction: r.instruction,
58-
type: r.type,
59-
priority: r.priority,
60-
}))
51+
let initial_name: string
52+
let initial_description: string | null | undefined
53+
let initial_instruction: string
54+
let initial_thinking_instruction: string | null | undefined
55+
let initial_requirements: Array<{
56+
name: string | undefined
57+
instruction: string | undefined
58+
type: string | undefined
59+
priority: number | undefined
60+
}>
6161
6262
function reset_initial_values() {
6363
initial_name = task.name
@@ -71,6 +71,7 @@
7171
priority: r.priority,
7272
}))
7373
}
74+
reset_initial_values()
7475
7576
function requirements_changed(
7677
reqs: Task["requirements"],
@@ -79,21 +80,21 @@
7980
if (reqs.length !== initial.length) return true
8081
return reqs.some(
8182
(r, i) =>
82-
r.name !== initial[i].name ||
83-
r.instruction !== initial[i].instruction ||
84-
r.type !== initial[i].type ||
83+
(r.name || "") !== (initial[i].name || "") ||
84+
(r.instruction || "") !== (initial[i].instruction || "") ||
85+
(r.type || "") !== (initial[i].type || "") ||
8586
r.priority !== initial[i].priority,
8687
)
8788
}
8889
8990
// Warn before unload only if there are actual changes from the initial state
9091
$: warn_before_unload =
91-
!saved &&
92-
(task.name !== initial_name ||
93-
task.description !== initial_description ||
94-
task.instruction !== initial_instruction ||
95-
task.thinking_instruction !== initial_thinking_instruction ||
96-
requirements_changed(task.requirements, initial_requirements))
92+
task.name !== initial_name ||
93+
(task.description || "") !== (initial_description || "") ||
94+
task.instruction !== initial_instruction ||
95+
(task.thinking_instruction || "") !==
96+
(initial_thinking_instruction || "") ||
97+
requirements_changed(task.requirements, initial_requirements)
9798
9899
// Allow explicitly setting project ID, or infer current project ID
99100
export let explicit_project_id: string | undefined = undefined

0 commit comments

Comments
 (0)