feat(freecad): add Silo-aware start page with webview and offline fallback #57
Reference in New Issue
Block a user
Delete Branch "feat/silo-start-page"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replaces the default FreeCAD Start page with a dual-mode view:
The command override is registered at InitGui.py load time, before
the C++ StartLauncher fires.
Implement the full Bill of Materials stack on top of the existing relationships table and bom_single_level view from migration 001. API endpoints (6 new routes under /api/items/{partNumber}/bom): - GET /bom Single-level BOM for an item - GET /bom/expanded Multi-level BOM via recursive CTE (depth param) - GET /bom/where-used Reverse lookup: which parents use this item - POST /bom Add child to BOM with quantity, ref designators - PUT /bom/{child} Update relationship type, quantity, ref des - DELETE /bom/{child} Remove child from BOM Database layer (internal/db/relationships.go): - RelationshipRepository with full CRUD operations - Single-level BOM query joining relationships with items - Multi-level BOM expansion via recursive CTE (max depth 20) - Where-used reverse lookup query - Cycle detection at insert time to prevent circular BOMs - BOMEntry and BOMTreeEntry types for denormalized query results Server wiring: - Added RelationshipRepository to Server struct in handlers.go - Registered BOM routes in routes.go under /{partNumber} subrouter FreeCAD workbench (pkg/freecad/silo_commands.py): - 9 new BOM methods on SiloClient (get, expanded, where-used, add, update, delete) - Silo_BOM command class with two-tab dialog: - BOM tab: table of children with Add/Edit/Remove buttons - Where Used tab: read-only table of parent assemblies - Add sub-dialog with fields for part number, type, qty, unit, ref des - Edit sub-dialog pre-populated with current values - Remove with confirmation prompt - silo-bom.svg icon matching existing toolbar style - Command registered in InitGui.py toolbar No new migrations required - uses existing relationships table and bom_single_level view from 001_initial.sql.Rework the FreeCAD client authentication to match the Silo backend's actual auth implementation (local, LDAP, OIDC/Keycloak, API tokens). Auth model change: - Remove the old AuthToken/AuthTokenExpiry session-token approach - Unify on API tokens (ApiToken preference / SILO_API_TOKEN env var) as the single auth mechanism for the desktop client - _get_auth_token() now delegates to _get_api_token() directly - All requests use Bearer token auth via _get_auth_headers() SiloClient.login() rewrite: - POST form-encoded credentials to /login (matching the backend's form-based login handler, works with local and LDAP backends) - Use the resulting session cookie to call GET /api/auth/me to get user info (username, role, auth_source) - Create a persistent API token via POST /api/auth/tokens named 'FreeCAD (hostname)' with 90-day expiry - Store the raw token in ApiToken preference for all future requests - No more ephemeral session tokens — API tokens survive restarts New SiloClient methods: - get_current_user(): GET /api/auth/me, returns user dict or None - refresh_auth_info(): fetches /api/auth/me and updates cached prefs - auth_role(): returns stored role (admin/editor/viewer) - auth_source(): returns stored auth source (local/ldap/oidc) - list_tokens(): GET /api/auth/tokens - create_token(name, expires_in_days): POST /api/auth/tokens - revoke_token(token_id): DELETE /api/auth/tokens/{id} New preference keys: - AuthRole: cached user role from server - AuthSource: cached auth source (local, ldap, oidc) Removed preference keys: - AuthToken: replaced by ApiToken (was duplicative) - AuthTokenExpiry: API tokens have server-side expiry Auth helper changes: - _save_auth_info(): stores username, role, source, and optionally token - _clear_auth(): clears ApiToken, AuthUsername, AuthRole, AuthSource - _get_auth_role(), _get_auth_source(): new accessors Dock widget updates: - New Role row showing role and auth source (e.g. 'editor (ldap)') - Status refresh validates token against /api/auth/me on each poll - Four status states: Connected (green), Token invalid (orange), Connected no auth (yellow), Disconnected (red) - Caches validated user info back to preferences Login dialog updates: - Info text explains the flow (creates persistent API token) - Placeholder text updated (removed LDAP-specific wording) - Shows 'Logging in...' status during auth - Displays role and auth source on success - Disables login button during request Settings dialog updates: - API Token input field with show/hide toggle - Token can be pasted directly from Silo web UI - Hint text explains token sources (web UI, Login, env var) - 'Clear Token and Logout' button replaces old clear credentials - Save handler persists token changes - Status summary shows role and auth source check_connection() fix: - Uses origin /health (not /api/health) matching actual route Fixes the endpoint mismatch where client was calling a non-existent POST /api/auth/login JSON endpoint. Now uses the actual form-based POST /login + session cookie flow that the backend implements.Calc extension (pkg/calc/): - Python UNO ProtocolHandler with 8 toolbar commands - SiloClient HTTP client adapted from FreeCAD workbench - Pull BOM/Project: populates sheets with 28-col format, hidden property columns, row hash tracking, auto project tagging - Push: row classification, create/update items, conflict detection - Completion wizard: 3-step category/description/fields with PN conflict resolution dialog - OpenRouter AI integration: generate standardized descriptions from seller text, configurable model/instructions, review dialog - Settings: JSON persistence, env var fallbacks, OpenRouter fields - 31 unit tests (no UNO/network required) Go ODS library (internal/ods/): - Pure Go ODS read/write (ZIP of XML, no headless LibreOffice) - Writer, reader, 10 round-trip tests Server ODS endpoints (internal/api/ods.go): - GET /api/items/export.ods, template.ods, POST import.ods - GET /api/items/{pn}/bom/export.ods - GET /api/projects/{code}/sheet.ods - POST /api/sheets/diff Documentation: - docs/CALC_EXTENSION.md: extension progress report - docs/COMPONENT_AUDIT.md: web audit tool design with weighted scoring, assembly computed fields, batch AI assistance plan- New /audit page with completeness scoring engine - Weighted scoring by sourcing type (purchased vs manufactured) - Batch DB queries for items+properties, BOM existence, project codes - API endpoints: GET /api/audit/completeness, GET /api/audit/completeness/{pn} - Audit UI: tier summary bar, filterable table, split-panel inline editing - Create item form now shows category-specific property fields on category select - Properties collected and submitted with item creationPull request closed