From 359a976dc381685c073dc65246e0f1c545444ccb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:53:58 +0000 Subject: [PATCH 1/4] Initial plan From 35811abe42df40d5c5b51c25c98cab18c8486062 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:57:44 +0000 Subject: [PATCH 2/4] Initial plan for processing Want #676 Co-authored-by: aarongustafson <75736+aarongustafson@users.noreply.github.com> --- wants/180227d4-332e-4ded-93e0-8d587f8ab215.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 wants/180227d4-332e-4ded-93e0-8d587f8ab215.md diff --git a/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md b/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md new file mode 100644 index 0000000..4425a34 --- /dev/null +++ b/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md @@ -0,0 +1,11 @@ +--- +title: +date: +submitter: +number: 180227d4-332e-4ded-93e0-8d587f8ab215 +tags: [ ] +discussion: +status: discussing +related: +--- + From 2479e3eeabfb28832b141d6f64c40fc288195499 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 17:04:27 +0000 Subject: [PATCH 3/4] Create want file and fix YAML parser bugs - Created want file 180227d4-332e-4ded-93e0-8d587f8ab215.md - Fixed YAML parser to handle array initialization - Fixed YAML parser to preserve indentation for nested object detection - Fixed YAML parser to create new objects for each array item Co-authored-by: aarongustafson <75736+aarongustafson@users.noreply.github.com> --- scripts/utils/frontmatter.mjs | 52 +++++++++++-------- wants/180227d4-332e-4ded-93e0-8d587f8ab215.md | 30 +++++++++-- 2 files changed, 56 insertions(+), 26 deletions(-) diff --git a/scripts/utils/frontmatter.mjs b/scripts/utils/frontmatter.mjs index 0907f9b..b98084b 100644 --- a/scripts/utils/frontmatter.mjs +++ b/scripts/utils/frontmatter.mjs @@ -54,41 +54,61 @@ function parseYaml(yamlText) { let multilineValue = ''; for (let line of lines) { - line = line.trim(); + const originalLine = line; + const trimmedLine = line.trim(); // Skip empty lines and comments - if (!line || line.startsWith('#')) { + if (!trimmedLine || trimmedLine.startsWith('#')) { continue; } // Handle multiline strings (for content after frontmatter) if (inMultilineString) { - if (line === '---' || line === '...') { + if (trimmedLine === '---' || trimmedLine === '...') { inMultilineString = false; if (currentKey) { result[currentKey] = multilineValue.trim(); } multilineValue = ''; } else { - multilineValue += line + '\n'; + multilineValue += trimmedLine + '\n'; } continue; } + // Handle object properties within arrays (indented with spaces, not starting with -) + if (originalLine.match(/^\s+\w+:/) && !trimmedLine.startsWith('-') && currentObject) { + const colonIndex = trimmedLine.indexOf(':'); + if (colonIndex > 0) { + const key = trimmedLine.substring(0, colonIndex).trim(); + const value = trimmedLine.substring(colonIndex + 1).trim(); + currentObject[key] = parseValue(value); + } + continue; + } + + // Now work with trimmed line for the rest + line = trimmedLine; + // Handle array items if (line.startsWith('- ')) { const value = line.substring(2).trim(); + // Initialize array if we have a currentKey but no array yet + if (currentKey && !currentArray) { + result[currentKey] = []; + currentArray = result[currentKey]; + } + // Check if this is an object in an array (like related links) if (value.includes(':')) { const objMatch = value.match(/^(\w+):\s*(.+)$/); if (objMatch) { const [, key, objValue] = objMatch; - if (!currentObject) { - currentObject = {}; - if (currentArray) { - currentArray.push(currentObject); - } + // Create a new object for this array item + currentObject = {}; + if (currentArray) { + currentArray.push(currentObject); } currentObject[key] = parseValue(objValue); } @@ -97,18 +117,8 @@ function parseYaml(yamlText) { if (currentArray) { currentArray.push(parseValue(value)); } - } - continue; - } - - // Handle object properties within arrays (indented) - if (line.startsWith(' ') && currentObject) { - const objLine = line.substring(2); - const colonIndex = objLine.indexOf(':'); - if (colonIndex > 0) { - const key = objLine.substring(0, colonIndex).trim(); - const value = objLine.substring(colonIndex + 1).trim(); - currentObject[key] = parseValue(value); + // Reset currentObject since this is not an object array item + currentObject = null; } continue; } diff --git a/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md b/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md index 4425a34..0f3f12a 100644 --- a/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md +++ b/wants/180227d4-332e-4ded-93e0-8d587f8ab215.md @@ -1,11 +1,31 @@ --- -title: -date: -submitter: +title: I want upload hints for browsers to open appropriate system folders in the file picker +date: 2025-10-31T16:54:44.670Z +submitter: Tactile-Taco number: 180227d4-332e-4ded-93e0-8d587f8ab215 -tags: [ ] -discussion: +tags: + - html + - forms + - api +discussion: https://github.com/WebWeWant/webwewant.fyi/discussions/676 status: discussing related: + - title: File API Specification + url: https://w3c.github.io/FileAPI/ + type: spec + - title: HTML input element + url: https://html.spec.whatwg.org/#the-input-element + type: spec --- +Navigating my filesystem every time I need to upload something to a website is a time-consuming pain. When I click to upload a file—whether it's my resume for a job application, a photo for a profile, or a document for a form—the file browser always opens in my home folder or the last-used location. From there, I have to navigate through multiple folders to find what I need. + +I want upload fields to provide hints about what type of file I'm uploading so the browser can intelligently open the file picker in the most appropriate folder. For example, when uploading a resume to a job application, the browser could open directly to my "Career" folder or wherever my resume is stored. When uploading a photo, it could open to my Pictures folder. + +The browser could use various signals to determine the best location: +- Semantic hints from the webpage (e.g., `accept` attribute, form field labels, or additional metadata) +- User's file organization patterns and frequently accessed folders +- Previous upload history for similar file types +- Common file naming patterns (e.g., files containing "resume" or "CV") + +This would save time and reduce friction in the upload process, making web forms feel more intelligent and user-friendly. \ No newline at end of file From fa68c637a014c83a1c8f281d1c9fdf8cbafb40d9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 17:09:26 +0000 Subject: [PATCH 4/4] Improve YAML parser performance per code review - Extract regex patterns outside loop for better performance - Add helper function ensureArray() to reduce code duplication - Use pre-compiled regex patterns throughout parser Co-authored-by: aarongustafson <75736+aarongustafson@users.noreply.github.com> --- scripts/utils/frontmatter.mjs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/utils/frontmatter.mjs b/scripts/utils/frontmatter.mjs index b98084b..027ed3d 100644 --- a/scripts/utils/frontmatter.mjs +++ b/scripts/utils/frontmatter.mjs @@ -53,6 +53,20 @@ function parseYaml(yamlText) { let inMultilineString = false; let multilineValue = ''; + // Pre-compile regex patterns for better performance + const indentedPropertyRegex = /^\s+\w+:/; + const objectPropertyRegex = /^(\w+):\s*(.+)$/; + + /** + * Initialize array for current key if not already initialized + */ + const ensureArray = () => { + if (currentKey && !currentArray) { + result[currentKey] = []; + currentArray = result[currentKey]; + } + }; + for (let line of lines) { const originalLine = line; const trimmedLine = line.trim(); @@ -77,7 +91,7 @@ function parseYaml(yamlText) { } // Handle object properties within arrays (indented with spaces, not starting with -) - if (originalLine.match(/^\s+\w+:/) && !trimmedLine.startsWith('-') && currentObject) { + if (indentedPropertyRegex.test(originalLine) && !trimmedLine.startsWith('-') && currentObject) { const colonIndex = trimmedLine.indexOf(':'); if (colonIndex > 0) { const key = trimmedLine.substring(0, colonIndex).trim(); @@ -95,14 +109,11 @@ function parseYaml(yamlText) { const value = line.substring(2).trim(); // Initialize array if we have a currentKey but no array yet - if (currentKey && !currentArray) { - result[currentKey] = []; - currentArray = result[currentKey]; - } + ensureArray(); // Check if this is an object in an array (like related links) if (value.includes(':')) { - const objMatch = value.match(/^(\w+):\s*(.+)$/); + const objMatch = objectPropertyRegex.exec(value); if (objMatch) { const [, key, objValue] = objMatch; // Create a new object for this array item