Repository navigation
feat(id-native-shell): trusted form widgets for presented forms (#8938, native half) - #11434
Conversation
… native half) The native shell projected every presented form as text: its session layer had no form handling at all, so a form_result could never be sent and a presented form was a dead end (the web half landed in PR #11324; the SSH terminal is the third presenter). Add a pure FormPresenter (src/form.rs) mirroring world_ssh.rs: - widgets are built only from this client's own input manifest plus the closed FormField/FormAction model (no markup from the program); - a form without a presentation token, or one whose fields this presenter's manifest cannot collect, renders no actionable widget and falls back to the surface's escape-free text projection; - form_result_frame carries the view's form_id and current presentation_token; a cancel sends no values (reference behaviour); - settle() mirrors the SSH token rotation, including the retry alias so a redraw carrying the program's stale token keeps the host's token. session.rs now validates and retains form_result_status (the contract already names it), render.rs renders widget lines through a new PresentedForm resource, and main.rs folds each drained view through the presenter. Tests: tests/form_widgets.rs drives real session frames — submit and cancel frame identity, rejection re-presents with the returned token and the next answer uses it, and an untrusted manifest renders nothing. Unit tests cover the presenter, and render tests prove a trusted form draws widgets while an untrusted one falls back to text.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 390628b73b
ℹ️ 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".
| let grid = match (form.0.active(), form.0.widgets()) { | ||
| (Some(_), Some(widgets)) => ScreenGrid::from_text(&form_widget_lines(&widgets).join("\n")), | ||
| _ => ScreenGrid::from_view(view), |
There was a problem hiding this comment.
Wire form rows to editable controls and submit/cancel handlers
When a live session presents a trusted form, this branch still converts every field and action into plain text; the subsequent renderer only creates Text/TextSpan entities. There is no field-value state or input/action handler calling FormPresenter::answer, and SessionBridge::_outbound remains unused by the UI. Consequently, users cannot fill, submit, or cancel any of the newly displayed forms—the new integration tests only invoke the frame builder directly. Add interactive controls or keyboard form handling and send their resulting frames through the session channel.
Useful? React with 👍 / 👎.
| self.form_result_status = Some(frame); | ||
| Ok(ServerUpdate::FormResultStatus) |
There was a problem hiding this comment.
Forward form-result statuses to the live presenter
When the host sends form_result_status, storing it here does not deliver it to the running UI: run_session_inner only forwards ServerUpdate::View through the views channel, and neither take_form_result_status nor PresentedForm::apply_status has a production caller. A rejection therefore never installs its replacement presentation token, and an acceptance or terminal rejection never clears the displayed form. Forward these statuses across the session bridge and fold them into PresentedForm while the session is running, rather than retaining them until the session returns.
Useful? React with 👍 / 👎.
| for action in &widgets.actions { | ||
| lines.push(format!( | ||
| "[{}]{}", | ||
| action.id, |
There was a problem hiding this comment.
Preserve user-facing action labels in the form display
For valid forms whose action IDs are opaque, such as a1 labeled “Keep draft” and a2 labeled “Publish”, the trusted rendering now displays only [a1] and [a2], discarding the information explaining what each action does. Previously, FormSurface::text_projection() displayed each action's label, and FormWidgetAction still retains that label. Render action.label, optionally alongside the ID if it serves as a keyboard shortcut, so switching to the trusted presentation does not remove the action descriptions.
Useful? React with 👍 / 👎.
What
The native shell projected every presented form as text: its session layer had no form handling at all, so a presented form was a dead end in that client. This is the native half of #8938 — the web half merged as #11324; the SSH terminal is the third presenter.
pkgs/id/crates/id-native-shell/src/form.rs(new) — a pureFormPresentermirroringworld_ssh.rs:FormField/FormActionmodel (no markup from the program);presentation_token, or one whose fields this manifest cannot collect, renders no actionable widget and falls back to the surface's escape-free text projection;form_result_framecarries the view'sform_id+ currentpresentation_token, and a cancel sends no values;settle()mirrorsworld_ssh.rstoken rotation, including the retry alias so a redraw carrying the program's stale token keeps the host-issued one.session.rs— validates and retainsform_result_status(already named by the contract) asServerUpdate::FormResultStatus, consumable once.render.rs— newPresentedFormresource; a trusted form renders widget lines, everything else renders as before.main.rs— each drained view is folded through the presenter.Tests
cargo test -p id-native-shell --lib --test form_widgets— 46 + 6 pass:form_resultframes carry the rightform_id+ token;form_result_statusrejection re-presents with the returned token and the next answer uses the rotated token;Oracle
world_ssh.rs(SSH presenter, PR #8928) andcontract/shell-contract.v1.json.Closes #8938.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.