Commit graph

17 commits

Author SHA1 Message Date
Kayshen-X 8f8b36b76f docs: fix stale i18n + renderer paths flagged by Codex review 2026-05-16 15:45:54 +08:00
Kayshen-X d9ada6cc11 docs(mcp): correct read-tool count 17→18 in catalog 2026-05-15 22:10:00 +08:00
Kayshen-X 5373b83b09 docs(mcp): refresh tool catalog 21→77 + add AI chat section
- crates/CLAUDE.md MCP catalog was stale at 21 tools; replace the
  outdated table with the current 77-tool categorized summary and
  point at mcp_serve.rs TOOL_SCHEMAS as the source of truth.
- Refresh the mcp/ file-layout list (node_attr_tools,
  selected_ops_tools, extra_read_tools, json_serializer, …).
- New "AI chat (real provider integration)" section documenting
  begin_send / ChatProvider / chat_session / the model chip and
  the Codex/OpenCode honest-error behavior.
- chat_session: gate the test-only `finished()` accessor behind
  `#[cfg(test)]` to drop a dead-code warning.
2026-05-15 22:06:42 +08:00
Kayshen-X 4311b5ec7b docs(crates): clean up stale "Eight" + duplicate HttpServer line
Cosmetic — tool count was still "Eight" from the previous
revision, and the HttpServer pending bullet was duplicated.
2026-05-14 23:25:09 +08:00
Kayshen-X 9985caeccf docs(crates): add design_skeleton/content/refine to tool catalog
Layered design workflow shipped in 7cee053d. Update CLAUDE.md:
- 3 new rows in the tool catalog table (21 tools total now)
- Tools/list note updated 18 → 21
- Pending list trimmed (design_* line removed; replaced with
  the next-tier work: per-phase apply semantics, JSON Node parser
  for subtree shapes, HttpServer wire protocol verification)
2026-05-14 23:24:28 +08:00
Kayshen-X e71aa319bb docs(crates): document batch_design + scalar_vars + --mcp host wiring
Updates the MCP server section in crates/CLAUDE.md to reflect
today's shipped work:

- Tool catalog grew from 8 → 18 (added batch_design + 3 scalar
  variable tools + host wiring closes BLOCKER #1)
- File layout includes the new mcp/batch_design.rs + mcp/
  scalar_vars.rs + their sibling test files
- New "Host wiring" subsection explains
  `openpencil-desktop --mcp <path>` lifecycle + handshake
- Pending list updated: layered design workflow tools
  (design_skeleton/content/refine) + JSON Node parser remain
2026-05-14 23:20:34 +08:00
Kayshen-X e1a639e3fb docs(crates): document MCP write-tool catalog + wire hardening
Adds a new "MCP server (shell-core)" section to
crates/CLAUDE.md covering:

- The 14-tool catalog (6 read + 8 write) with arg shapes and
  emitted McpCommand variants per tool.
- Pre-validate-then-mutate discipline at the apply layer.
- `replace_node`'s `drop_children` destructive-swap guard.
- Wire-format stop-gates (structured-arg rejection, top-level
  `arguments` walker, no-hang on parse failure, read-only path
  refusing write tools).
- mcp/ file layout including the sibling test files for
  copy_node and replace_node.
- Pending: host wiring, batch_design / design_skeleton tools,
  HttpServer transport.
2026-05-14 22:31:58 +08:00
Kayshen-X 1a194efc3d feat(shell): canonical .op loader + jian-core layout + visual fidelity pass
Pivot the desktop's Open path to the canonical `jian-ops-schema`
parser and route layout through `jian-core::LayoutEngine` so files
saved by the TS editor, Jian apps, or any tool emitting the
canonical schema load through the shared parser + paragraph shaper.

Loader (pen_doc_adapter.rs + pen_doc_path_bounds.rs)

- All 12 PenNode variants → NodePayload, with each root's authored
  (base.x, base.y) added to harvested rects so multi-design files
  (e.g. pencil-demo.op's 14 mockups) spread across the canvas.
- Path anchors port `getPathBoundsFromAnchors` — endpoints + Bezier
  handles + cubic-derivative extrema — so curved paths scale into
  their (width, height) the way the canonical renderer paints.
- jian-skia's `SkiaMeasure` plugged in via
  `LayoutEngine::with_backend(...)`, replacing the ~10% character-
  count heuristic with real paragraph-shaper metrics. Wrap/layout
  now agree with paint instead of cascading 10% errors.
- Numeric-string fontWeight (`"700"`, `"normal"`, ...) parsed in
  both jian-core and the desktop adapter; expanded keyword table
  covers black/heavy/extralight/extrabold/demibold/hairline/etc.
- Version-tolerant `load_canonical` retries with `version` rewritten
  to `"1.0"` so legacy `version: "2.8"` files still load.

Text + icon rendering

- `Node.text_wrap` gated on `textGrowth: fixed-width` — single-line
  by default so font-fallback overshoot doesn't break lines the TS
  app shows on one line.
- CJK-aware `wrap_text` (canvas_viewport_overlay.rs) — per-char CJK
  breaks, word breaks for Latin, blank-line preservation, explicit
  `\n` splits. Takes a weight param.
- `RenderBackend::measure_text_weighted` added with NativeBackend +
  WebBackend overrides so wrap measurement matches weighted paint.
- icons.rs + new icons_data.rs sibling cover ~75 lucide variants
  for first-party `iconFontName` names from pen-core element-builders
  (trending-up/down, compass, refresh-cw, layout-dashboard, users,
  package, zap, sliders-horizontal, activity, loader, focus,
  chart-line, settings-2, arrow-right, check-circle, alert-triangle,
  alert-octagon, sticky-note, bar-chart-2, bold/italic/underline,
  shopping-cart/bag, send, message-circle, rocket, menu, credit-card,
  x-circle, mail, smartphone, chrome, apple, user, ...). Unknown
  names stroke a dot fallback (FALLBACK_ICON_D) instead of a block.
  All d-strings copied from lucide-react@0.545.0.
- `Icon::from_name(&str)` resolves kebab-case + common aliases.
- Synthetic bold via PaintStyle::StrokeAndFill for weights ≥600 on
  both native and web (single-weight bundles can't serve a real
  bold variant).

Chrome polish

- Hover state on file menu / locale picker / shape picker / layer
  panel rows / AgentSettings nav + provider cards. Host's
  apply_cursor_move updates each per its open state.
- File menu compacted (row 30, header 22, no `…` suffix on actions),
  recent file names truncate with a CJK-aware helper.
- `rfd::MessageDialog` on every failed Open / OpenRecent / Save /
  SaveAs / ExportImage with bilingual (EN/ZH) title + path + detail.
  OpenRecent failures prune the stale entry.
- `figma_import.rs` modal honest-stub (Coming soon copy, brand glyph),
  TopBar Folder+Chevron compound + Figma button.
- Settings sidebar nav + provider cards tinted on hover.
- Recent-files panel polished to single-line names with age column.

Tests

- pen_doc_adapter_tests.rs (sibling via #[path]) — 19 cases covering
  multi-root canvas offsets, shape size fallbacks, path anchor
  absolutize + Bezier extrema, fixed-width wrap, numeric-string
  weights, login.op + pencil-demo.op fixture loads.
- canvas_viewport_overlay.rs wrap_tests — 7 cases: ASCII / CJK /
  CJK+Latin / explicit-newline / blank-line / weighted advances.
- icons.rs first_party_icon_font_names_all_resolve guards 27+
  authored names against placeholder regressions.

File-cap discipline

- pen_doc_adapter.rs split into mod + path-bounds sibling + tests
  sibling.
- icons.rs split into mod + icons_data.rs sibling so the catalogue
  can grow without busting the cap.
- canvas_viewport_overlay.rs absorbs wrap_text + UniformBackend /
  WeightedBackend test stubs.

Sub-modules

- vendor/jian advanced for `resolve_weight` numeric-string parsing.
2026-05-14 09:26:08 +08:00
Kayshen-X d109ed206e docs(shell): refresh crates/CLAUDE.md for v0.8.0 surface
Catch crates/CLAUDE.md up with the v0.8.0 work that landed across
the last few sessions:

- document/ split: add pen.rs, color_picker.rs, grouping.rs,
  page_mutators.rs to the split rationale
- UiState diagram: add settings_input_draft, agent_settings (focus,
  tab, connected, mcp_server, mcp_cli_enabled, images_*,
  hover_provider), color_picker, pen_in_progress + pen_cursor_doc,
  layer_context_menu, page_context_menu, property_tab
- Node: document corner_radius field + the round-rect rendering
  threshold; mention NodeKind::Path (multi-anchor polylines)
- RenderBackend: note new fill_svg_path primitive for brand logos
- Widgets table: add brand_icons, color_picker, layer_context_menu,
  agent_settings_* rows
- PropertyFocus: list PositionR as a wired variant
- New sections: Settings modal (Cmd+,), Settings input editing,
  Pen tool, Color picker (HSV), Layer right-click + drag-into-
  container, Hot-path optimizations (VecDeque history, static
  i18n, viewport culling, redraw scheduler, cursor coalescing,
  font cache prewarm), Native widget_host layout expanded to 8
  submodules including property_dispatch.rs + shortcuts.rs
2026-05-12 22:04:08 +08:00
Kayshen-X 4784b267f9 docs(shell): note document.rs directory split in crates/CLAUDE.md
The 800-line cap section in `crates/CLAUDE.md` listed `widget_host`
and `property_panel` as the two split files; `document.rs` joined
them on 2026-05-11 (commit 512ed9b7). Updated the file-cap bullet
and the Document model heading to point at the directory.
2026-05-11 21:42:44 +08:00
Kayshen-X 2cda18318d feat(shell): selection handles + drag-create + per-node flags + LayerPanel polish
Re-apply 4 reset commits (1854dfa6 → b94274c6) bundled with session
follow-ons. Native + web hosts share the new behavior end-to-end.

Selection + canvas interaction:
- bounded Frame drag now translates descendants too
- 8 selection handles with hover-cursor feedback
- thinner selection outline + smaller AA handles
- handle-drag resize for rect/ellipse/polygon/line/frame/text
- drag-to-create shapes / frames / text from the active tool
- per-NodeKind hit-test (oval / triangle / line slack / point-in-poly)
- rotation pivot is kind-aware (handles negative-size Lines)

Per-node flags (TS parity):
- Node.hidden / locked / collapsed / fill_type (moved off Document.ui)
- mutators gated by is_editable / is_subtree_editable so locked /
  hidden subtrees can't be translated, resized, rotated, recolored,
  or deleted as collateral

Multi-select + marquee + clipboard + keyboard shortcuts:
- selected_set + anchor; shift+click toggles set membership
- marquee rect-select with screen-px threshold + ADD-only shift
- copy / cut / paste / duplicate / nudge / reorder / select-all
- escape one-layer-per-press priority cascade (property-focus →
  locale picker → shape picker → fill-type picker → chat → selection)
- Cmd-letter chord guards (!shift) so Cmd-Shift-letter doesn't fall
  through to text input; !modifier guards on named keys

LayerPanel polish:
- hover-reveal eye/lock affordances (TS parity)
- Eye → EyeOff icon when hidden; Lock → LockOpen when unlocked
- locked Lock renders in warm orange
- chevron expand/collapse for container rows; collapsed subtree
  hides from tree (paint/hit-test unaffected)
- `+` add-page button wired end-to-end (mints fresh id past
  max_node_id + 1, names "Page N", overflow-safe)
- smaller, refined trailing icons (12 px @ 1.2 stroke)
- 18 px chevron-to-kind-icon gap

RenderBackend trait grew fill_oval / stroke_oval / fill_polygon /
stroke_polygon / rotate so both native and web backends can paint
the new node shapes.

Refactor:
- split native widget_host.rs (1799 lines) into spine + 7 sibling
  submodules under widget_host/ to stay under the 800-line ceiling
- split web widget_host.rs into spine + paint + keyboard siblings
- amend tools/check-widget-boundary.sh + spec § 1.4 to allow
  widget_host/* sibling files; tighten `// glue:` marker rule to
  the immediately-preceding line (rustfmt-stable)

Stop-hook iterations addressed:
- allocator overflow guards (checked_add) on duplicate / paste /
  add_page paths
- subtree-size precheck before any id mint in deep_clone
- hidden subtree skipped in paint AND selection overlay
- nested protected delete leak closed via is_subtree_editable
- per-FocusKind hex/numeric input gating; sticky `#` prefix on hex
- ScaleFactorChanged refreshes viewport from window.inner_size()

122 shell-core tests pass; cargo fmt --all --check clean;
cargo check --workspace clean; widget boundary check clean.
2026-05-11 21:30:06 +08:00
Kayshen-X f4a569b002 docs(shell): note PropertyPanel editing + Toolbar shape dropdown + desktop crate
* crates/CLAUDE.md — add ShapePicker widget row, PropertyPanel
  X/Y/W/H editing section, Toolbar shape-tool dropdown spec, expanded
  Tool variants, updated UiState bullet listing all the new fields,
  Document::commit_property_edit + Tool::is_shape() helpers.
2026-05-10 23:17:18 +08:00
Kayshen-X db69fc5fc7 refactor(shell): promote inspector_window to openpencil-desktop binary crate
The native runner outgrew the `examples/` slot — it owns DPI tracking,
caret-blink animation timer, panel-resize cursor, the full Cmd+wheel /
PinchGesture / Pixel/LineDelta dispatch table, etc. None of that is a
sample, so it's been promoted to a real crate.

* New crate `crates/openpencil-desktop/` with a single `[[bin]]`
  target. Depends on `openpencil-shell-native` (lib) + winit +
  skia-safe (gl), gated to macOS / Linux / Windows.
* `examples/inspector_window.rs` removed; equivalent code lives at
  `crates/openpencil-desktop/src/main.rs` with the structs renamed
  (DesktopApp / paint) and the doc-block rewritten as a runner spec.
* Run command: `cargo run -p openpencil-desktop --release`. Old
  command (`--example inspector_window`) is gone.
* Workspace glob `crates/*` already picks up the new crate, no
  Cargo.toml workspace edit needed.
* Docs: crates/CLAUDE.md updated with the new crate row and runner
  section retitled "Desktop binary". Top-bar layout test renamed +
  uses the TOP_BAR_HEIGHT constant so future height tweaks stop
  breaking it.
2026-05-10 19:50:10 +08:00
Kayshen-X 333403a0c7 docs(shell): note empty-agent chip, locale picker, multi-script, chat parity
* crates/CLAUDE.md — register LocalePicker widget, canvas_surface token,
  ai.tipSelectElements key, multi-script per-codepoint font cache.
* TopBar Globe section now describes the 44 px globe-plus-chevron
  compound and the click-anywhere-to-close behaviour.
2026-05-10 19:34:28 +08:00
Kayshen-X c6020e3aeb docs(shell): document the i18n + theme toggle infrastructure
crates/CLAUDE.md gains an 'i18n' row + 'Theme + i18n' section that
covers Document::theme()/t() + the 15 locale tables generated
from TS. Includes the convert-locales.py re-run command for
contributors who change TS strings.
2026-05-10 19:08:17 +08:00
Kayshen-X e92ed98203 docs(shell): note canvas_region invariant for collapsed sidebar
Recent codex stop-hook iterations exposed three sites where input
hit-test hardcoded LAYER_PANEL_WIDTH while paint followed
canvas_region (which collapses to 0 when sidebar is closed):
over_canvas, apply_wheel cursor offset, toolbar hit rect. Document
the invariant so future widgets don't re-introduce the drift.
2026-05-10 17:57:07 +08:00
Kayshen-X a578178842 docs(shell): add crates/CLAUDE.md for the Rust shell
Documents the crate layout, key invariants (wasm32-clean shell-core,
800-line file ceiling, web bundle 1 MiB / 0 env.* imports), Document
model, widget catalog, RenderBackend surface, native + web runner
specifics, hit-test order, and the perf gotchas (native chrome paint
605ms→sub-ms via cached typeface path; skia matrix reset; jian DrawOp
bypass for line + round-rect + svg-path).
2026-05-10 17:16:29 +08:00