[codex] Add typed LibreOffice workbook handles#125
Conversation
📝 WalkthroughWalkthroughImplements typed workbook handles for LibreOffice extraction operations. Introduces Changes
Sequence DiagramsequenceDiagram
participant Backend as LibreOfficeRichBackend
participant Session as LibreOfficeSession
participant WbRegistry as Workbook Registry
participant Cache as Bridge Payload Cache
participant Bridge as Bridge Subprocess
rect rgba(100, 150, 200, 0.5)
Note over Backend,Bridge: New Typed Workbook Lifecycle (with Handle)
Backend->>Session: load_workbook(file_path)
Session->>WbRegistry: register workbook
Session-->>Backend: LibreOfficeWorkbookHandle
Backend->>Session: extract_chart_geometries(handle)
Session->>Session: resolve & validate handle
Session->>Bridge: extract with resolved path
Bridge-->>Session: geometry data
Session->>Cache: store with (kind, path) key
Session-->>Backend: geometries
Backend->>Session: close_workbook(handle)
Session->>Session: validate ownership
Session->>Cache: clear entries for workbook path
Session->>WbRegistry: unregister workbook
Session-->>Backend: success
end
rect rgba(150, 100, 200, 0.5)
Note over Backend,Bridge: Legacy Fallback (Path-only, no lifecycle)
Backend->>Session: extract_chart_geometries(file_path)
Session->>Session: check for load/close support
alt Unsupported
Session->>Bridge: extract_chart_geometries(file_path)
Bridge-->>Session: geometries
end
Session-->>Backend: geometries
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly Related Issues
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 31 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
Summary
LibreOfficeSession.load_workbook()token with a typedLibreOfficeWorkbookHandlesession_factoryimplementations that only support legacy path-based extractionWhy
LibreOfficeSessionexposed a public-looking workbook lifecycle API but returned an untypeddicttoken and treatedclose_workbook()as a no-op. That made the contract easy to misuse and gave type checkers almost no useful guarantees.Impact
LibreOfficeSessioncallers can use a typed workbook handle safelysession_factorystubs that only implementextract_draw_page_shapes()/extract_chart_geometries()continue to workRoot Cause
The original LibreOffice session lifecycle was left as a placeholder after the rich extraction backend landed, so the backend had no typed workbook handle contract and no meaningful close semantics.
Validation
uv run pytest tests/core/test_libreoffice_backend.py -quv run task precommit-runSummary by CodeRabbit
New Features
Bug Fixes
Improvements
Closes #77