Skip to content

Commit 3b7af24

Browse files
Fix profile import fidelity, add wizard filament selection, real vendor filament library
1 parent 6d20c87 commit 3b7af24

79 files changed

Lines changed: 88561 additions & 20045 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

HANDOFF_CHATGPT.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# OrcaSlicer Mobile — Session Handoff (2026-06-11)
2+
3+
For the next AI continuing this work. Read this fully before touching anything.
4+
5+
## Project context
6+
7+
- **Repo**: `/home/cody/workspace/OrcaSlicerMobileTestHandOffToGemini` (this is the CORRECT folder; ignore `OrcaSlicerMobileTest`)
8+
- **What it is**: Android slicer (SliceBeam shell, package `ru.ytkab0bp.slicebeam`, appId `com.codemastercody3d.orcaslicermobile`) with the real OrcaSlicer libslic3r engine ported via JNI
9+
- **GitHub**: https://github.com/CodeMasterCody3D/OrcaSlicer-Mobile — local branch `engine-swap` pushes to remote `master` (`git push origin engine-swap:master`). Release v0.1.0 exists.
10+
- **Build**: `./gradlew assembleDebug``app/build/outputs/apk/debug/OrcaSlicerMobile_<hash>.apk` (~72MB now)
11+
- **User's phone**: adb device `R5CR60DKJGB`. Install: `adb -s R5CR60DKJGB install -r <apk>`. User prefers to run on-device tests themselves — give steps, don't drive taps.
12+
- **User is new to git** — explain in plain language, run git for them.
13+
- Sliced G-code lives at `/data/data/com.codemastercody3d.orcaslicermobile/cache/temp.gcode` on device; pull with `adb shell "run-as com.codemastercody3d.orcaslicermobile cat <path>" > local.gcode`.
14+
- Reference files: desktop `/home/cody/gcode/3DBenchy_PLA_34m50s.gcode`, `/home/cody/gcode/Stanford_Bunny_PLA_3h52m.gcode`; user's printer bundle `/home/cody/Desktop/Kreality Ender 3 Pro KlipperBlueBoy 0.4 nozzle.orca_printer`.
15+
16+
## Architecture cheat-sheet (verified, don't re-derive)
17+
18+
- Java `ConfigObject` stores config values; `put()/get()` rename keys through `KEY_MIGRATION` (legacy PrusaSlicer name ↔ Orca engine name), so values are STORED under Orca names. `ConfigObject.serialize()` writes flat `key = value` INI which the native side loads with `DynamicPrintConfig::load()`.
19+
- `Slic3rConfigWrapper.PRINT/FILAMENT/PRINTER_CONFIG_KEYS` are import whitelists (legacy names mostly, Orca names allowed too — the check is `contains(key) || contains(legacyKey(key))`). **Anything not whitelisted is silently dropped at import.**
20+
- `IOUtils.configJsonToIni(json, type, supportedKeys, inBundle)` converts Orca JSON profiles (from .orca_printer/.orca_filament bundles) → ConfigObject. `IOUtils.mapOrcaConfigKey` = `ConfigObject.legacyKey()` + special case `chamber_temperatures→chamber_temperature`.
21+
- Setup wizard = `SetupActivity` (ViewPager2, pages are SimpleRecyclerItems): Intro(0), PresetChoice(1), Profiles(2=PROFILES_INDEX), **Filaments(3, NEW this session)**, [Boosty], Finish. Bundled vendor INIs in `app/src/main/assets/orca_profiles/*.ini`, generated by `orcaslicer_mobile_assets/orca_ini_generator.py` from `resolved_orcaslicer_profiles.json` (built by `profile_builder.py` from `_orca_profiles_clone/resources/profiles`).
22+
- Engine BedType enum: `curr_bed_type` selects which `*_plate_temp` slots are used. App UI's bed temperature = legacy `bed_temperature` → stored as `hot_plate_temp`, so native pins `curr_bed_type = High Temp Plate (btPEI)` when unset (beam_native.cpp, after `config.normalize_fdm()`).
23+
24+
## What was done THIS session (all uncommitted!)
25+
26+
### Round 1 — G-code parity fixes (user compared mobile vs desktop Benchy/Bunny output)
27+
1. `Slic3rConfigWrapper.java`: **removed `ironing_type "no ironing" → "top"` inversion** (parse path) — it was force-ENABLING ironing (244 ironing passes, +2h print time). Also removed `crosshatch→grid` coercion (Orca engine understands crosshatch).
28+
2. Whitelist additions:
29+
- PRINT: `only_one_wall_top`, `initial_layer_infill_speed`, `elefant_foot_compensation_layers`, `enable_arc_fitting`, `wall_direction`, `slowdown_for_curled_perimeters`, `xy_hole_compensation`, `default_jerk`, `outer_wall_jerk`, `inner_wall_jerk`, `infill_jerk`, `top_surface_jerk`, `initial_layer_jerk`, `travel_jerk`
30+
- FILAMENT: all plate temps (`cool/eng/textured/textured_cool/supertack_plate_temp` + `_initial_layer`), `additional_cooling_fan_speed`, `overhang_fan_threshold`
31+
- PRINTER: `enable_filament_ramming`, `curr_bed_type`
32+
3. `ConfigObject.java` KEY_MIGRATION: added `xy_size_compensation → xy_contour_compensation`.
33+
4. `IOUtils.mapOrcaConfigKey`: **removed `initial_layer_infill_speed → first_layer_speed_over_raft`** (that legacy key doesn't exist in the Orca engine → value died at config.load).
34+
5. `beam_native.cpp` (`Java_..._model_1slice`, right after `config.normalize_fdm()`): pin `curr_bed_type` to `btPEI` when unset — **the app's bed temperature setting was dead UI before this** (engine read Cool Plate slots = 35°C instead of user's 55°C).
35+
6. Result verified on device: Benchy mobile 32m vs desktop 34m50s (was 5h53m vs 3h52m class of error on Bunny). ironing/only_one_wall_top/enable_filament_ramming now match desktop exactly.
36+
37+
### Round 2 — Setup wizard filament selection (user request: like desktop, with select all/deselect all)
38+
7. `orca_ini_generator.py` rewritten in parts:
39+
- PROCESS_KEY_MAP fixed: `initial_layer_infill_speed`→itself, `xy_hole_compensation`→itself (was typo'd `x_size_compensation`), `enable_arc_fitting`→itself; added jerks/wall_direction/only_one_wall_top/slowdown_for_curled_perimeters/elefant_foot_compensation_layers.
40+
- PROCESS_VALUE_MAP reduced to only `("support_material_pattern","normal")→"default"`.
41+
- MACHINE_KEY_MAP: added `nozzle_diameter`, `min/max_layer_height`, full retraction block (`retraction_length→retract_length`, `z_hop→retract_lift`, `z_hop_types`, `travel_slope`, speeds, wipe, toolchange extras). `MACHINE_COMMA_VECTOR_KEYS` set comma-joins numeric/enum vectors (engine INI needs commas; `;` only for string vectors). Machine-limit keys included.
42+
- NEW `FILAMENT_KEY_MAP` + `filament_family_name()` (strips " @Machine") + `vendor_filament_profiles()` (groups ~4000 per-machine variants into per-family sections, prefers exact-family-named base, requires ≥1 instantiated variant).
43+
- `main()`: emits real vendor filaments (generics only as fallback), real per-model `default_materials` from `machine_model` entries (variant names mapped → family names), `default_filament_profile` family-stripped.
44+
- **Assets regenerated**: `app/src/main/assets/orca_profiles/` — 64 vendors, 7.8MB. Creality has 102 filaments, BBL 206. Regenerate with `cd orcaslicer_mobile_assets && python3 orca_ini_generator.py`.
45+
8. `SetupActivity.java`:
46+
- New fields `filamentsItem`, `enabledFilaments`.
47+
- `ProfileItem.ProfileHolderView`: `getList(item)` + `switch(item.type)` now keyed off the BOUND item (was outer-instance field — latent recycling bug).
48+
- New `FilamentsItem` page class (after ProfilesItem class): lists filaments of vendors that have an enabled printer, grouped under vendor headers, `ProfileItem(fil, TYPE_FILAMENT)` rows, inner `SelectAllItem` row (Select all / Deselect all buttons), Next button. `refreshIfNeeded()` rebuilds when printer selection changed (guard key = custom-flag + printer titles); also hooked in `onPageScrolled` at `position == PROFILES_INDEX + 1`. Pre-checks `default_materials` of selected printer models.
49+
- Inserted into `setItems()` after `profilesItem`.
50+
- `FinishItem`: installs `enabledFilaments` (dedup by title); legacy default_materials lookup only runs if `enabledFilaments` empty.
51+
9. `strings.xml`: `IntroFilamentsHeader`, `IntroFilamentsSelectAll`, `IntroFilamentsDeselectAll`, `IntroFilamentsNone` (English only; ru.po not updated).
52+
10. `IOUtils.java`: removed BOTH remaining ironing-inversion blocks (in `downloadProfilesRecursively` merge loop and `configJsonToIni` inherited-keys loop).
53+
54+
### Round 3 — .orca_printer import bugs (user report: filaments "missing", selectors greyed out, selection resets)
55+
Diagnosis (verified):
56+
- The user's bundle DOES contain 11 filament templates + 1 process; they DO import. The visible bug: `ConfigObject.profileListType` defaults to 0 = `PROFILE_LIST_PRINT`, and `IOUtils.configJsonToIni` never set it → `isSelected()` compares filament/printer titles against the WRONG presets slot → selectors show nothing selected (greyed), and any manual selection appears to vanish on rebind.
57+
11. **FIX APPLIED**: `IOUtils.configJsonToIni` now sets `cfg.profileListType` from the `type` param ("process"/"filament"/"machine"). Covers both SetupActivity and MainActivity import paths.
58+
12. `SetupActivity.ensureImportedDefaults`: default filament preset now prefers a title containing "PLA" instead of first-alphabetical (was picking ABS).
59+
60+
## ⚠️ CURRENT STATE / IMMEDIATE NEXT STEP
61+
62+
- Follow-up verification after this handoff: `./gradlew :app:assembleDebug --no-daemon --console=plain --rerun-tasks` completed successfully with `:app:compileDebugJavaWithJavac`, dexing, and `:app:packageDebug` executed (not stale/up-to-date-only). Generated APK: `app/build/outputs/apk/debug/OrcaSlicerMobile_6d20c87c77.apk` (59,174,943 bytes). Installed to adb device `R5CR60DKJGB` with `adb install -r``Success`.
63+
- Bytecode check confirmed the installed-build source path contains the Round-3 fix: `IOUtils.configJsonToIni()` switches on `type` and writes `ConfigObject.profileListType` to 0/1/2 for `process`/`filament`/`machine` before import inheritance processing.
64+
- **Next step is behavioral on-device verification**: have the user wipe app data (or fresh install), import `/home/cody/Desktop/Kreality Ender 3 Pro KlipperBlueBoy 0.4 nozzle.orca_printer` at the setup screen, and check: printer chip shows "Kreality Ender 3 Pro KlipperBlueBoy 0.4 nozzle" selected, filament selector shows a PLA template selected, and selections survive navigating away/back. Do not commit until that passes.
65+
66+
## Remaining known gaps / ideas (not started)
67+
68+
- `.orca_printer` import only brings the bundle's own filaments (same as desktop). The big vendor library only appears via the preset wizard path. Could offer the Filaments page after bundle import too.
69+
- OrcaFilamentLibrary vendor (filament-only, no machines) is skipped by the generator — desktop shows it for all printers.
70+
- `ru.po` lacks the 4 new Intro strings (falls back to English).
71+
- APK is 72MB (7.8MB of INI assets). Could trim per-vendor or compress further if it matters.
72+
- User's already-imported profiles on the phone predate the whitelist fixes — they must **re-import** the .orca_printer/.orca_filament bundles (or re-run setup) to pick up dropped keys (flow ratio 0.98, jerks, initial_layer_infill_speed=105, xy compensation, etc.).
73+
- NOTHING from this session is committed. `git add -A && git commit` when user confirms testing, then `git push origin engine-swap:master`. Suggested message: "Fix profile import fidelity, add wizard filament selection, real vendor filament library".
74+
75+
## Per-user notes
76+
77+
- Be plain-spoken about git (user is new to it).
78+
- The user paints models differently on desktop vs mobile, so multicolor G-code diffs are expected to differ in toolpaths — compare CONFIG_BLOCK settings, not raw moves.
79+
- Earlier session fixed: flush_volumes_matrix N×N rebuild in beam_native.cpp, MultiMaterialSegmentation static-init wall-paint bug (thresholds computed per-call now), machine_max_feedrate_* KEY_MIGRATION entries, retraction-group whitelist, README rewrite, GitHub publish + v0.1.0 release.

0 commit comments

Comments
 (0)