Repository navigation
refactor: renew rendering and source boundary contracts - #279
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR systematically removes unsafe typing casts and tightens JSON/value contracts by introducing explicit runtime validation helpers ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 399d94b6f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not text and not content_blocks: | ||
| continue |
There was a problem hiding this comment.
Preserve text-only block content when retaining empty-text messages
This new guard keeps messages whenever content_blocks is present, but non-structured blocks (like type: "text") still render HTML from msg.text inside build_rendered_message. For inputs such as text="" with content_blocks=[{"type":"text","text":"hello"}], the message is now included but its HTML body is empty, creating blank message shells in both conversation/projection views. This regression appears whenever upstream data stores text in blocks but leaves the legacy text field empty.
Useful? React with 👍 / 👎.
## Summary - renew rendering, source, and decoder boundary contracts around block payloads and dispatch - tighten follow-through across provider helpers, drive/source support, and plain-console rendering tests - eliminate the remaining hotspot seams in this slice without reopening the verification-renewal diff ## Problem The next high-leverage source-side weak typing and payload-plumbing debt was concentrated in the rendering/source boundary layer: - `polylogue/rendering/block_models.py` - `polylogue/rendering/core_messages.py` - `polylogue/sources/dispatch.py` - `polylogue/sources/token_store.py` - `polylogue/lib/json.py` Those files still carried cast-heavy extraction, loose `object`/sequence handling, and partially modeled provider/decoder seams. Adjacent helpers like drive support, ChatGPT/Claude/Gemini provider adapters, and the plain-console shim were then compensating for that imprecision. Closes #278 ## Solution - rebuilt the JSON/document helpers in `polylogue/lib/json.py` and `polylogue/sources/decoder_json.py` around typed validation rather than cast-driven loads - tightened renderable block/message handling in `polylogue/rendering/block_models.py`, `polylogue/rendering/blocks.py`, `polylogue/rendering/core_messages.py`, and `polylogue/rendering/renderers/html_messages.py` - removed source/provider hotspot casts across `polylogue/sources/dispatch.py`, `token_store.py`, `emitter.py`, `drive_source_client.py`, `drive_source_support.py`, `parsers/claude_index.py`, `parsers/claude_code_parser.py`, `parsers/drive_support_{attachments,blocks}.py`, and provider adapters under `polylogue/sources/providers/` - tightened the remaining boundary seams in `drive_auth.py`, `drive_gateway.py`, `blob_store.py`, and `ui/facade_console.py` - extended rendering/source law coverage with targeted tests for media blocks, HTML message rendering, output snapshots, and source detection/dispatch laws ## Verification - `ruff check tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.py polylogue/ui/facade_console.py` - `mypy tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.py polylogue/ui/facade_console.py` - `pytest -q tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.py` - `devtools verify`
The next high-leverage source-side debt was concentrated in the
rendering/source boundary: `rendering/block_models.py`,
`rendering/core_messages.py`, `sources/dispatch.py`,
`sources/token_store.py`, and `lib/json.py` still carried cast-heavy
extraction, loose `object` / sequence handling, and partially
modeled provider/decoder seams. Adjacent helpers (Drive support,
ChatGPT/Claude/Gemini provider adapters, the plain-console shim)
were compensating for that imprecision.
Rebuilds the JSON/document helpers in `lib/json.py` and
`sources/decoder_json.py` around typed validation rather than
cast-driven loads. Tightens renderable block/message handling in
`rendering/block_models.py`, `blocks.py`, `core_messages.py`, and
`renderers/html_messages.py`. Removes source/provider hotspot casts
across `sources/dispatch.py`, `token_store.py`, `emitter.py`,
`drive_source_client.py`, `drive_source_support.py`,
`parsers/claude_index.py`, `parsers/claude_code_parser.py`,
`parsers/drive_support_{attachments,blocks}.py`, and provider
adapters under `sources/providers/`. Tightens remaining boundary
seams in `drive_auth.py`, `drive_gateway.py`, `blob_store.py`, and
`ui/facade_console.py`.
Extends rendering/source law coverage with targeted tests for media
blocks, HTML message rendering, output snapshots, and source
detection/dispatch laws.
Verification: ruff + mypy + pytest over rendering/UI suites;
devtools verify green.
Closes #278
The next high-leverage source-side debt was concentrated in the
rendering/source boundary: `rendering/block_models.py`,
`rendering/core_messages.py`, `sources/dispatch.py`,
`sources/token_store.py`, and `lib/json.py` still carried cast-heavy
extraction, loose `object` / sequence handling, and partially
modeled provider/decoder seams. Adjacent helpers (Drive support,
ChatGPT/Claude/Gemini provider adapters, the plain-console shim)
were compensating for that imprecision.
Rebuilds the JSON/document helpers in `lib/json.py` and
`sources/decoder_json.py` around typed validation rather than
cast-driven loads. Tightens renderable block/message handling in
`rendering/block_models.py`, `blocks.py`, `core_messages.py`, and
`renderers/html_messages.py`. Removes source/provider hotspot casts
across `sources/dispatch.py`, `token_store.py`, `emitter.py`,
`drive_source_client.py`, `drive_source_support.py`,
`parsers/claude_index.py`, `parsers/claude_code_parser.py`,
`parsers/drive_support_{attachments,blocks}.py`, and provider
adapters under `sources/providers/`. Tightens remaining boundary
seams in `drive_auth.py`, `drive_gateway.py`, `blob_store.py`, and
`ui/facade_console.py`.
Extends rendering/source law coverage with targeted tests for media
blocks, HTML message rendering, output snapshots, and source
detection/dispatch laws.
Verification: ruff + mypy + pytest over rendering/UI suites;
devtools verify green.
Closes #278
The next high-leverage source-side debt was concentrated in the
rendering/source boundary: `rendering/block_models.py`,
`rendering/core_messages.py`, `sources/dispatch.py`,
`sources/token_store.py`, and `lib/json.py` still carried cast-heavy
extraction, loose `object` / sequence handling, and partially
modeled provider/decoder seams. Adjacent helpers (Drive support,
ChatGPT/Claude/Gemini provider adapters, the plain-console shim)
were compensating for that imprecision.
Rebuilds the JSON/document helpers in `lib/json.py` and
`sources/decoder_json.py` around typed validation rather than
cast-driven loads. Tightens renderable block/message handling in
`rendering/block_models.py`, `blocks.py`, `core_messages.py`, and
`renderers/html_messages.py`. Removes source/provider hotspot casts
across `sources/dispatch.py`, `token_store.py`, `emitter.py`,
`drive_source_client.py`, `drive_source_support.py`,
`parsers/claude_index.py`, `parsers/claude_code_parser.py`,
`parsers/drive_support_{attachments,blocks}.py`, and provider
adapters under `sources/providers/`. Tightens remaining boundary
seams in `drive_auth.py`, `drive_gateway.py`, `blob_store.py`, and
`ui/facade_console.py`.
Extends rendering/source law coverage with targeted tests for media
blocks, HTML message rendering, output snapshots, and source
detection/dispatch laws.
Verification: ruff + mypy + pytest over rendering/UI suites;
devtools verify green.
Closes #278
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Problem
The next high-leverage source-side weak typing and payload-plumbing debt was concentrated in the rendering/source boundary layer:
polylogue/rendering/block_models.pypolylogue/rendering/core_messages.pypolylogue/sources/dispatch.pypolylogue/sources/token_store.pypolylogue/lib/json.pyThose files still carried cast-heavy extraction, loose
object/sequence handling, and partially modeled provider/decoder seams. Adjacent helpers like drive support, ChatGPT/Claude/Gemini provider adapters, and the plain-console shim were then compensating for that imprecision.Closes #278
Solution
polylogue/lib/json.pyandpolylogue/sources/decoder_json.pyaround typed validation rather than cast-driven loadspolylogue/rendering/block_models.py,polylogue/rendering/blocks.py,polylogue/rendering/core_messages.py, andpolylogue/rendering/renderers/html_messages.pypolylogue/sources/dispatch.py,token_store.py,emitter.py,drive_source_client.py,drive_source_support.py,parsers/claude_index.py,parsers/claude_code_parser.py,parsers/drive_support_{attachments,blocks}.py, and provider adapters underpolylogue/sources/providers/drive_auth.py,drive_gateway.py,blob_store.py, andui/facade_console.pyVerification
ruff check tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.py polylogue/ui/facade_console.pymypy tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.py polylogue/ui/facade_console.pypytest -q tests/unit/rendering/test_rendering.py tests/unit/ui/test_ui.pydevtools verify