← Commit history
v2.1.12: - **The search bar is tidier.** "Per vendor" sits beside the 3 / 5 / 10 box and lines up with it, rather than wedged into the box's corner. In a narrow window the controls stay on one row with the Search button on the right; only at phone width does the button take a row of its own.
9 files changed
+73−96
Cargo.lock+1−1@@ -10,7 +10,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adom-parts-search"-version = "2.1.11"+version = "2.1.12" dependencies = [ "base64", "clap",
Cargo.toml+1−1@@ -1,6 +1,6 @@ [package] name = "adom-parts-search"-version = "2.1.11"+version = "2.1.12" edition = "2021" description = "Parts Search Electronics component search — CLI, backend HTTP service, and Hydrogen webview app" license = "MIT"
VERSION+1−1@@ -1 +1 @@-2.1.11+2.1.12
install.shpackage.json+1−40@@ -34,44 +34,5 @@ "SKILL.md", "BUILD-SKILL.md", "CHANGELOG.md"- ],- "changelog": "- **The search bar is tidier.** \"Per vendor\" sits beside the 3 / 5 / 10 box and lines up with it, rather than wedged into the box's corner. In a narrow window the controls stay on one row with the Search button on the right; only at phone width does the button take a row of its own.",- "discovery_triggers": [- "parts search",- "find part",- "source component",- "source part",- "compare distributors",- "compare vendors",- "Mouser or DigiKey",- "BOM sourcing",- "price this part",- "where can I get",- "check stock",- "parts availability",- "fastest delivery",- "cheapest part",- "component search",- "part lookup",- "price breaks"- ],- "discovery_pitch": "Search Mouser, DigiKey and JLCPCB in parallel with product photos; Mouser-preferred best-source pick. Say 'with parts search' to your AI.",- "sample_prompts": [- {- "label": "source an STM32F103RBT6",- "prompt": "source an STM32F103RBT6"- },- {- "label": "where can I get an ESP32-S3-WROOM cheape",- "prompt": "where can I get an ESP32-S3-WROOM cheapest and fastest"- },- {- "label": "compare Mouser, DigiKey and JLCPCB for a",- "prompt": "compare Mouser, DigiKey and JLCPCB for an LM555"- },- {- "label": "price this BOM across distributors",- "prompt": "price this BOM across distributors"- } ]-}+}
page.json+7−44@@ -36,22 +36,10 @@ "path": "docs/hero.png" }, "sample_prompts": [- {- "label": "source an STM32F103RBT6",- "prompt": "source an STM32F103RBT6"- },- {- "label": "where can I get an ESP32-S3-WROOM cheape",- "prompt": "where can I get an ESP32-S3-WROOM cheapest and fastest"- },- {- "label": "compare Mouser, DigiKey and JLCPCB for a",- "prompt": "compare Mouser, DigiKey and JLCPCB for an LM555"- },- {- "label": "price this BOM across distributors",- "prompt": "price this BOM across distributors"- }+ "source an STM32F103RBT6",+ "where can I get an ESP32-S3-WROOM cheapest and fastest",+ "compare Mouser, DigiKey and JLCPCB for an LM555",+ "price this BOM across distributors" ], "discovery_triggers": [ "parts search",@@ -66,37 +54,12 @@ "where can I get", "check stock", "parts availability",- "fastest delivery",- "cheapest part",- "component search",- "part lookup",- "price breaks"+ "fastest delivery" ],- "discovery_pitch": "Search Mouser, DigiKey and JLCPCB in parallel with product photos; Mouser-preferred best-source pick. Say 'with parts search' to your AI.",+ "discovery_pitch": "Search Mouser + DigiKey + JLCPCB in parallel from one interface, with product photos and a Mouser-preferred best-source pick.", "metadata": { "platform": "linux" }, "category": "tools",- "org": "adom",- "description": "One search box across Mouser, DigiKey and JLCPCB. Parallel queries, side-by-side product photos, and a Mouser-preferred recommendation that reasons around stock and lead time. Dock Bar ready: serve, health, settings, Say it.",- "dependencies": {},- "needs_sudo": false,- "scripts": {- "install": "./install.sh",- "uninstall": "./uninstall.sh"- },- "files": [- "bin/**",- "skills/**",- "docs/icon.svg",- "dockbar.json",- "install.sh",- "uninstall.sh",- "package.json",- "README.md",- "SKILL.md",- "BUILD-SKILL.md",- "CHANGELOG.md"- ],- "changelog": "- **The search bar is tidier.** \"Per vendor\" sits beside the 3 / 5 / 10 box and lines up with it, rather than wedged into the box's corner. In a narrow window the controls stay on one row with the Search button on the right; only at phone width does the button take a row of its own."+ "org": "adom" }
src/app/ui.html+15−9@@ -127,12 +127,13 @@ main>:first-child{margin-top:0} .ex:active{transform:translateY(1px) scale(.97)} .searchbar input::placeholder{color:var(--text-2);text-overflow:ellipsis} .sb-controls{display:flex;gap:8px;align-items:center;flex:none}-.seg{display:inline-flex;background:var(--elevated);border:1px solid var(--border);border-radius:8px;padding:2px;gap:2px}+.seg{display:inline-flex;align-items:center;background:var(--elevated);border:1px solid var(--border);border-radius:8px;padding:2px;gap:2px} .seg button{min-width:34px;height:32px;padding:0 8px;border:none;border-radius:6px;background:transparent;color:var(--text-2);font:500 13px var(--mono);cursor:pointer;transition:background .15s ease,color .15s ease,transform .06s ease} .seg button:hover{background:var(--overlay);color:var(--text)} .seg button:active{transform:scale(.95)} .seg button[aria-pressed="true"]{background:var(--accent);color:var(--on-accent);box-shadow:inset 0 0 0 1px rgba(0,0,0,.15)}-.seg-label{font-size:12px;color:var(--text-2);margin-right:2px}+.seg-label{font-size:12px;color:var(--text-2);white-space:nowrap}+.sb-limit{display:inline-flex;align-items:center;gap:8px;flex:none} .toggle{background:none;border:none;padding:2px;cursor:pointer;flex-shrink:0;transition:transform .06s ease;display:inline-flex;align-items:center} .toggle-track{display:block;width:32px;height:18px;background:var(--overlay);border:1px solid var(--border);border-radius:9px;position:relative;transition:background .15s ease,border-color .15s ease} .toggle:hover .toggle-track{border-color:var(--accent)}@@ -383,8 +384,8 @@ select.sel:disabled{opacity:.5;cursor:not-allowed} main{padding:20px 10px 40px} .searchbar{flex-wrap:wrap;padding:8px} .sb-field{flex:1 1 100%;order:1}- .sb-controls{order:2;flex:1 1 100%;justify-content:space-between;flex-wrap:wrap;gap:6px}- .sb-controls .btn{flex:1 1 100%;min-height:44px}+ .sb-controls{order:2;flex:1 1 100%;flex-wrap:wrap;gap:8px 12px;padding:2px 2px 0}+ .sb-controls .btn{margin-left:auto;min-height:40px} .seg button{min-width:40px;height:36px} .toggle-row{min-height:44px} .app-footer .f-hide{display:none}@@ -396,6 +397,9 @@ select.sel:disabled{opacity:.5;cursor:not-allowed} dialog{width:100vw;max-height:100vh;border-radius:0} .settings-body{max-height:calc(100vh - 50px)} }+@media (max-width:480px){+ .sb-controls .btn{flex:1 1 100%;margin-left:0;min-height:44px}+} @media (hover:none),(pointer:coarse){ .iconbtn,.btn,.say-try{min-width:44px;min-height:44px} }@@ -438,11 +442,13 @@ select.sel:disabled{opacity:.5;cursor:not-allowed} <input id="q" name="keyword" type="text" placeholder="Part number or keyword, e.g. STM32F103RBT6 or LM358" aria-label="Part number or keyword" autofocus> </div> <div class="sb-controls">- <div class="seg" role="group" aria-label="Results per vendor" data-tooltip="How many hits to fetch from each vendor. 3 for a quick snapshot, 10 to compare variants. Higher costs more upstream API calls: Mouser's free tier is about 1000 per day.">- <span class="seg-label">per vendor</span>- <button type="button" data-limit="3" aria-pressed="false">3</button>- <button type="button" data-limit="5" aria-pressed="true">5</button>- <button type="button" data-limit="10" aria-pressed="false">10</button>+ <div class="sb-limit" data-tooltip="How many hits to fetch from each vendor. 3 for a quick snapshot, 10 to compare variants. Higher costs more upstream API calls: Mouser's free tier is about 1000 per day.">+ <span class="seg-label" id="limitLabel">Per vendor</span>+ <div class="seg" role="group" aria-labelledby="limitLabel">+ <button type="button" data-limit="3" aria-pressed="false">3</button>+ <button type="button" data-limit="5" aria-pressed="true">5</button>+ <button type="button" data-limit="10" aria-pressed="false">10</button>+ </div> </div> <label class="toggle-row" data-tooltip="On: hits with zero stock are dropped before rendering, for when you need the part today. Off: every match shows, including backorders and long-lead parts, for BOM research."> <button type="button" class="toggle" id="instock" role="switch" aria-checked="false" aria-label="In stock only"><span class="toggle-track"><span class="toggle-thumb"></span></span></button>
src/vendors.rs+47@@ -671,6 +671,7 @@ pub fn search_all( } agg.wiki = wiki_t.join().unwrap_or_default();+ request_from_vendor_hits(&mut agg); agg.wiki_hint = wiki_hint(&agg.wiki); agg.recommendation = if opts.policy == "cheapest" { pick_cheapest(&agg, &agg.query) } else { pick_winner(&agg, &agg.query) }; if agg.recommendation.is_none() {@@ -679,6 +680,31 @@ pub fn search_all( agg } +/// Component Ocean's candidates lookup (behind the wiki's request flow) can come back empty for a part its own vendor+/// search just found: for ALD1116, DigiKey lists ALD1116PAL and ALD1116SAL while candidates answers []. Then the+/// request offer names the orderable numbers the vendors found, in stock first, rather than the typed family, so the+/// factory is asked for a real part.+fn request_from_vendor_hits(agg: &mut AggregatedResults) {+ if agg.wiki.request.is_none() || !agg.wiki.candidates.is_empty() { return; }+ let alnum = |s: &str| s.chars().filter(|c| c.is_ascii_alphanumeric()).collect::<String>().to_uppercase();+ let q = alnum(&agg.query);+ if q.len() < 4 { return; }+ let mut seen = std::collections::HashSet::new();+ let mut found: Vec<&VendorHit> = agg.mouser.hits.iter().chain(agg.digikey.hits.iter()).chain(agg.jlcpcb.hits.iter())+ .filter(|h| alnum(&h.mpn).starts_with(&q) && seen.insert(alnum(&h.mpn))).collect();+ if found.is_empty() { return; }+ found.sort_by(|a, b| (b.stock > 0).cmp(&(a.stock > 0)));+ agg.wiki.candidates = found.iter().take(10).map(|h| json!({"mpn": h.mpn, "manufacturer": h.manufacturer,+ "source": h.vendor.display(), "stock": h.stock})).collect();+ let best = found[0].mpn.clone();+ if alnum(&best) != q {+ let mut offer = crate::wiki::request_offer(&best);+ offer["message"] = Value::String(format!("No Adom wiki page for {} yet. The vendors list it as {}: request that \+ and Adom's factory builds its page (symbol, footprint, 3D, datasheet).", agg.query.trim(), best));+ agg.wiki.request = Some(offer);+ }+}+ fn build_empty_state(agg: &AggregatedResults) -> EmptyState { let q = &agg.query; let m_ok = agg.mouser.ok; let d_ok = agg.digikey.ok; let j_ok = agg.jlcpcb.ok;@@ -1134,6 +1160,27 @@ mod empty_state_tests { assert!(e.explanation.contains("JLCPCB has 3700")); assert!(!e.explanation.contains("erroring")); }++ #[test]+ fn no_candidates_from_co_offers_the_part_numbers_the_vendors_found() {+ // ALD1116: DigiKey lists ALD1116SAL (0) and ALD1116PAL (19); CO's candidates lookup answered []+ let mk = |mpn: &str, stock: u64| VendorHit { mpn: mpn.into(), ..hit(Vendor::DigiKey, stock) };+ let ok = |h: Vec<VendorHit>| VendorBlock { ok: true, total: h.len() as u64, hits: h, ..Default::default() };+ let mut agg = AggregatedResults { query: "ald1116".into(), digikey: ok(vec![mk("ALD1116SAL", 0), mk("ALD1116PAL", 19), mk("LM358", 5)]), ..Default::default() };+ agg.wiki = crate::wiki::WikiBlock { ok: true, request: Some(crate::wiki::request_offer("ald1116")), ..Default::default() };+ request_from_vendor_hits(&mut agg);+ let mpns: Vec<&str> = agg.wiki.candidates.iter().filter_map(|c| c["mpn"].as_str()).collect();+ assert_eq!(mpns, ["ALD1116PAL", "ALD1116SAL"], "in stock first, unrelated hits left out");+ let offer = agg.wiki.request.as_ref().unwrap();+ assert_eq!(offer["mpn"], "ALD1116PAL");+ assert!(offer["message"].as_str().unwrap().contains("vendors list it as ALD1116PAL"));+ assert!(wiki_hint(&agg.wiki).unwrap().ends_with("Run: adom-parts-search request ALD1116PAL"));+ // candidates CO did send are kept as they are+ let mut agg2 = AggregatedResults { query: "ald1116".into(), digikey: ok(vec![mk("ALD1116PAL", 19)]), ..Default::default() };+ agg2.wiki = crate::wiki::WikiBlock { ok: true, request: Some(crate::wiki::request_offer("ald1116")), candidates: vec![json!({"mpn": "ALD1116SAL"})], ..Default::default() };+ request_from_vendor_hits(&mut agg2);+ assert_eq!(agg2.wiki.request.as_ref().unwrap()["mpn"], "ald1116");+ } } #[cfg(test)]
uninstall.sh