Copilot commented on code in PR #9578:
URL: https://github.com/apache/texera/pull/9578#discussion_r4656178992


##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.ts:
##########
@@ -76,20 +78,63 @@ import { FiltersInstructionsComponent } from 
"../filters-instructions/filters-in
 import { NzSelectComponent } from "ng-zorro-antd/select";
 import { FormsModule } from "@angular/forms";
 
-// The single-file input each language accepts besides .ipynb.
-const SCRIPT_INPUTS: Record<MigrationLanguage, { name: string; extension: 
string; uploadHint: string }> = {
+// What each language accepts, and where the modal takes it, so a mismatch can 
name the right place.
+const MIGRATION_INPUTS: Record<
+  MigrationLanguage,
+  {
+    name: string;
+    article: string;
+    // As a notebook's kernelspec.language or language_info.name gives it, 
lowercased.
+    kernelLanguage: string;
+    extension: string;
+    uploadHint: string;
+    notebookType: string;
+    fileTab: string;
+    folderTab: string;
+  }
+> = {
   python: {
     name: "Python",
+    article: "a",
+    kernelLanguage: "python",
     extension: "py",
     uploadHint: "Please upload a Jupyter Notebook (.ipynb) or a Python (.py) 
file.",
+    notebookType: "Python Notebook",
+    fileTab: "Python File",
+    folderTab: "Python Folder",
   },
   r: {
     name: "R",
+    article: "an",
+    kernelLanguage: "r",
     extension: "R",
     uploadHint: "Please upload an R Jupyter Notebook (.ipynb) or an R (.R) 
file.",
+    notebookType: "R Notebook",
+    fileTab: "R File",
+    folderTab: "R Folder",
   },
 };
 
+const MIGRATION_LANGUAGES = Object.keys(MIGRATION_INPUTS) as 
MigrationLanguage[];
+
+const MIGRATION_ERROR_DURATION_MS = 8000;
+
+/** The language a notebook declares, lowercased. Undefined when it declares 
none. */
+function notebookKernelLanguage(notebook: Notebook): string | undefined {
+  // Each field is normalized first, so a blank kernelspec still falls back to 
language_info.
+  return [notebook.metadata?.["kernelspec"]?.language, 
notebook.metadata?.["language_info"]?.name]
+    .map(value => `${value ?? ""}`.trim().toLowerCase())

Review Comment:
   Notebook metadata types are not validated, so `language_info.name: { 
"toString": null }` makes this coercion throw even when `kernelspec.language` 
is valid. The exception escapes `generateFromNotebook`, leaving the modal's 
close, Escape, and backdrop controls disabled. Normalize only string values so 
malformed metadata cannot interrupt the import error handling.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to