Skip to content

Conversation

@hotzenklotz
Copy link
Member

@hotzenklotz hotzenklotz commented Dec 10, 2025

This PR fixes the alignment of the button in the task creation form. Additionally, it replaces some of the custom CSS with standard antd components for consistency.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Navigate to Admin > Task
  • Click on "Add Task"
  • Verify that the form works
  • Verify that the button alignment is fixed

Issues:


(Please delete unneeded items, merge only when none are left open)

  • Added changelog entry (create a $PR_NUMBER.md file in unreleased_changes or use ./tools/create-changelog-entry.py)
  • Added migration guide entry if applicable (edit the same file as for the changelog)
  • Updated documentation if applicable
  • Adapted wk-libs python client if relevant API parts change
  • Removed dev-only changes like prints and application.conf edits
  • Considered common edge cases
  • Needs datastore update after deployment

@hotzenklotz hotzenklotz self-assigned this Dec 10, 2025
@hotzenklotz hotzenklotz added frontend css Something frontend styling related labels Dec 10, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

📝 Walkthrough

Walkthrough

Replaces lodash utilities with native/alternative helpers, migrates inline layout/styling to Ant Design components (Alert, Flex, Typography), refactors task creation object construction using omit/omitBy equivalents, and adjusts Row alignments/margins to fix button alignment in the task creation form.

Changes

Cohort / File(s) Change Summary
Task Creation Form Refactor
frontend/javascripts/admin/task/task_create_form_view.tsx
Replaced lodash utilities (uniq, omit/omitBy, isNil, isEqual) with native/alternative helpers; added Ant Design imports (Alert, Flex, Typography) and replaced inline-styled divs with those components; warnings moved to Alert; success/failure lists wrapped with Typography and made copyable/CSV-downloadable; Row alignments changed from "middle" to "bottom" and margins adjusted to fix button alignment; task creation/update/build flows refactored to use omit-based field exclusion (nmlFiles, baseAnnotation); added DownloadOutlined icon on download button; minor class and layout adjustments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus on:
    • Verify lodash replacements (uniq, omit/omitBy, isNil, isEqual) preserve original semantics and edge cases.
    • Confirm Row alignment/margin changes fix the alignment issue across screen sizes and do not introduce regressions.
    • Check Alert, Flex, Typography usage for accessibility, consistent theming, and responsive behavior.
    • Validate task object construction branches (NML vs non-NML) where fields are omitted.

Suggested reviewers

  • knollengewaechs
  • philippotto

Poem

🐰 I nibbled at code with careful might,
Trimmed lodash leaves and set buttons right.
Alerts now sing, text lines glow,
CSV crumbs I let them know —
A hop, a tweak, the form feels light. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main objective: fixing task creation alignment, which matches the primary change in the PR.
Description check ✅ Passed The description is directly related to the changeset, explaining the alignment fix and mention of component replacement with Ant Design components.
Linked Issues check ✅ Passed The PR addresses issue #8037 by fixing button alignment in the task creation form through component layout restructuring using Ant Design Flex components with adjusted alignment properties.
Out of Scope Changes check ✅ Passed The replacement of lodash utilities and CSS with Ant Design components are scope-aligned changes for modernizing the UI and fixing alignment issues as required by #8037.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-task-create-spacing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3c93c68 and 39c8954.

📒 Files selected for processing (1)
  • unreleased_changes/9142.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • unreleased_changes/9142.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hotzenklotz hotzenklotz changed the base branch from master to antd-v6 December 10, 2025 16:42
@hotzenklotz hotzenklotz changed the base branch from antd-v6 to master December 10, 2025 16:43
<Alert
showIcon
type="warning"
title="There were warnings during task creation"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title prop is already antd v6. Should be message for v5.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/javascripts/admin/task/task_create_form_view.tsx (2)

109-123: Fix impossible length check in downloadTasksAsCSV

tasks.length is never < 0, so this guard is effectively dead and the function will happily compute a filename even for an empty array (which can lead to Math.max(...[]) being called). Use <= 0 instead to short‑circuit on empty input.

 export function downloadTasksAsCSV(tasks: Array<APITask>) {
-  if (tasks.length < 0) {
+  if (tasks.length <= 0) {
     return;
   }
@@
-  const allProjectNames = uniq(tasks.map((task) => task.projectName)).join("_");
+  const allProjectNames = uniq(tasks.map((task) => task.projectName)).join("_");

360-407: Ensure nmlFiles is omitted from the NML task payload to be consistent with other branches

In the NML creation branch, nmlFiles is not being omitted from the newTask payload:

const newTask: NewNmlTask = {
  ...omit(formValues, "baseAnnotation"),
  boundingBox,
};

This is inconsistent with the update branch and non-NML creation branch, both of which omit both "nmlFiles" and "baseAnnotation". Since nmlFiles are extracted and passed separately as batchOfNmls to createTaskFromNML, they should not be included in the payload.

Apply the same omit pattern:

-            const newTask: NewNmlTask = {
-              ...omit(formValues, "baseAnnotation"),
-              boundingBox,
-            };
+            const newTask: NewNmlTask = {
+              ...omit(formValues, "nmlFiles", "baseAnnotation"),
+              boundingBox,
+            };
🧹 Nitpick comments (2)
frontend/javascripts/admin/task/task_create_form_view.tsx (2)

251-259: Create/Reload resource button layout changes

Adding marginBottom: "var(--ant-form-item-margin-bottom)" on the Col wrappers and using a fixed flex="40px" for the reload icon button should align these controls with neighboring form items and address the button misalignment issue.

As an optional future cleanup, you could wrap these in Form.Item with layout="inline" (supported per recent antd versions) to let the form system manage vertical spacing instead of relying on inline margins. Based on learnings, this would leverage Form.Item’s per‑item layout control.

Also applies to: 261-275


470-481: Validator logic using isEqual on taskResponse.status

Using isEqual to check taskResponse.status against { pending: 0, active: 0, finished: 1 } before auto‑filling datasetName/datasetId is reasonable and keeps the intent explicit. Just ensure that this “exactly one finished, none pending/active” condition really matches the allowed base‑annotation tasks; otherwise, this could be a bit strict if more finished instances should still be acceptable.

Also applies to: 484-503

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1238b1b and 8687bde.

📒 Files selected for processing (1)
  • frontend/javascripts/admin/task/task_create_form_view.tsx (22 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: hotzenklotz
Repo: scalableminds/webknossos PR: 8849
File: frontend/javascripts/viewer/view/action-bar/ai_job_modals/components/collapsible_split_merger_evaluation_settings.tsx:39-51
Timestamp: 2025-08-14T14:12:03.293Z
Learning: Since Ant Design version 5.18, Form.Item components support the layout prop (layout="horizontal", layout="vertical", layout="inline"), allowing individual form items to override the parent Form's layout setting. This enables mixed layouts within a single form and was added as a new API feature in v5.18 according to the official changelog.
Learnt from: hotzenklotz
Repo: scalableminds/webknossos PR: 8849
File: frontend/javascripts/viewer/view/action-bar/ai_job_modals/components/collapsible_split_merger_evaluation_settings.tsx:39-51
Timestamp: 2025-08-14T14:12:03.293Z
Learning: Since Ant Design version 5.18, Form.Item components support the layout prop (layout="horizontal", layout="vertical", etc.), allowing individual form items to override the parent Form's layout setting. This is a newer API addition that provides more granular control over form item layouts.
📚 Learning: 2025-08-14T14:12:03.293Z
Learnt from: hotzenklotz
Repo: scalableminds/webknossos PR: 8849
File: frontend/javascripts/viewer/view/action-bar/ai_job_modals/components/collapsible_split_merger_evaluation_settings.tsx:39-51
Timestamp: 2025-08-14T14:12:03.293Z
Learning: Since Ant Design version 5.18, Form.Item components support the layout prop (layout="horizontal", layout="vertical", etc.), allowing individual form items to override the parent Form's layout setting. This is a newer API addition that provides more granular control over form item layouts.

Applied to files:

  • frontend/javascripts/admin/task/task_create_form_view.tsx
📚 Learning: 2025-08-14T14:12:03.293Z
Learnt from: hotzenklotz
Repo: scalableminds/webknossos PR: 8849
File: frontend/javascripts/viewer/view/action-bar/ai_job_modals/components/collapsible_split_merger_evaluation_settings.tsx:39-51
Timestamp: 2025-08-14T14:12:03.293Z
Learning: Since Ant Design version 5.18, Form.Item components support the layout prop (layout="horizontal", layout="vertical", layout="inline"), allowing individual form items to override the parent Form's layout setting. This enables mixed layouts within a single form and was added as a new API feature in v5.18 according to the official changelog.

Applied to files:

  • frontend/javascripts/admin/task/task_create_form_view.tsx
🧬 Code graph analysis (1)
frontend/javascripts/admin/task/task_create_form_view.tsx (2)
frontend/javascripts/libs/utils.ts (1)
  • pluralize (1188-1196)
frontend/javascripts/components/async_clickables.tsx (1)
  • AsyncButton (64-78)
🪛 GitHub Check: frontend-tests
frontend/javascripts/admin/task/task_create_form_view.tsx

[failure] 170-170:
Type '{ showIcon: true; type: "warning"; title: string; description: string; }' is not assignable to type 'IntrinsicAttributes & AlertProps & RefAttributes'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: backend-tests
  • GitHub Check: build-smoketest-push
🔇 Additional comments (4)
frontend/javascripts/admin/task/task_create_form_view.tsx (4)

1-1: Imports and utility refactors look consistent

Switching to per-module lodash imports and adding Alert, Flex, Typography, DownloadOutlined, and pluralize aligns with the new usages below and should be tree-shaking‑friendly. No issues from a typing or bundling perspective.

Also applies to: 18-18, 24-24, 34-35, 43-49


176-197: Result modal layout and pluralization logic look solid

The use of Typography.Paragraph code, copyable failed‑task output, Flex to center the CSV buttons, DownloadOutlined icons, and pluralize in the modal title all read well and should improve UX. Deduplicating warnings with uniq(warnings) before passing them into the modal is also a nice touch to avoid noisy duplicates.

Also applies to: 199-247, 413-416


328-344: Using omitBy(defaultValues, isNil) for applyDefaults is appropriate

Filtering out only null/undefined values before calling form.setFieldsValue is a good way to avoid antd complaining about null fields, while preserving falsy but valid values like 0 or false. The subsequent destructuring to strip type before populating the form keeps the form state clean.


518-553: Row align="bottom" changes for form rows

Updating the dataset, task type, experience, project, and script rows to align="bottom" (with wrap={false}) should vertically align the right‑hand buttons with the bottom of their associated form items and address the misaligned button issue described in the PR.

These rows now have consistent layout semantics, and the change is localized to the admin task form. Just double‑check in the dev instance that this still behaves well on smaller widths where labels wrap.

Also applies to: 604-635, 637-677, 694-725, 727-749

Comment on lines 164 to 173
const warningsContent =
warnings.length > 0 ? (
<div>
<div style={subHeadingStyle}>
<WarningOutlined
style={{
color: "var(--ant-color-warning)",
}}
/>{" "}
There were warnings during task creation:
</div>
<div
style={{
whiteSpace: "pre-line",
}}
>
{warnings.join("\n")}
</div>
<Alert
showIcon
type="warning"
title="There were warnings during task creation"
description={warnings.join("\n")}
/>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

find . -name "package.json" -type f | head -5

Repository: scalableminds/webknossos

Length of output: 139


🏁 Script executed:

rg "antd" package.json | head -20

Repository: scalableminds/webknossos

Length of output: 87


🏁 Script executed:

cat frontend/javascripts/admin/task/task_create_form_view.tsx | sed -n '160,180p'

Repository: scalableminds/webknossos

Length of output: 627


Replace title with message in Alert component

The Alert component in antd 5.x uses the message prop for the main content, not title. Additionally, render warnings as a list instead of joining with "\n", which won't display as line breaks.

         <Alert
           showIcon
           type="warning"
-          title="There were warnings during task creation"
-          description={warnings.join("\n")}
+          message="There were warnings during task creation"
+          description={
+            warnings.length === 1 ? (
+              warnings[0]
+            ) : (
+              <ul>
+                {warnings.map((w) => (
+                  <li key={w}>{w}</li>
+                ))}
+              </ul>
+            )
+          }
         />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const warningsContent =
warnings.length > 0 ? (
<div>
<div style={subHeadingStyle}>
<WarningOutlined
style={{
color: "var(--ant-color-warning)",
}}
/>{" "}
There were warnings during task creation:
</div>
<div
style={{
whiteSpace: "pre-line",
}}
>
{warnings.join("\n")}
</div>
<Alert
showIcon
type="warning"
title="There were warnings during task creation"
description={warnings.join("\n")}
/>
</div>
const warningsContent =
warnings.length > 0 ? (
<div>
<Alert
showIcon
type="warning"
message="There were warnings during task creation"
description={
warnings.length === 1 ? (
warnings[0]
) : (
<ul>
{warnings.map((w) => (
<li key={w}>{w}</li>
))}
</ul>
)
}
/>
</div>
🧰 Tools
🪛 GitHub Check: frontend-tests

[failure] 170-170:
Type '{ showIcon: true; type: "warning"; title: string; description: string; }' is not assignable to type 'IntrinsicAttributes & AlertProps & RefAttributes'.

🤖 Prompt for AI Agents
In frontend/javascripts/admin/task/task_create_form_view.tsx around lines
164-173, the Alert currently uses the obsolete title prop and joins warnings
with "\n"; replace title with the antd 5.x message prop and render warnings as a
real list instead of a newline-joined string (e.g., set message="There were
warnings during task creation" and set description to a JSX list such as
<ul>{warnings.map((w,i)=><li key={i}>{w}</li>)}</ul> or equivalent) so each
warning displays on its own line.

Copy link
Contributor

@knollengewaechs knollengewaechs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the spacing! The form still works well, but the success modal has a slight linebreak / formatting issue:
image

Please let me know if I am wrong – I assume this depends on the antd v6 PR, so I will test again after that is merged. Next to that, maybe add a small changelog entry?

@hotzenklotz
Copy link
Member Author

@knollengewaechs Thanks for the review. I fixed the line break issue and "downgraded" the <Alert> prop to match antd v5, so this PR is not blocked.

Screenshot 2025-12-12 at 10 17 38

Copy link
Contributor

@knollengewaechs knollengewaechs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thank you!

@hotzenklotz hotzenklotz merged commit 37f0da2 into master Dec 16, 2025
5 checks passed
@hotzenklotz hotzenklotz deleted the fix-task-create-spacing branch December 16, 2025 09:20
@coderabbitai coderabbitai bot mentioned this pull request Dec 17, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

css Something frontend styling related frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix button alignment in task creation view

3 participants