Skip to content

feat(serve): record approve and decline from the browser (#347) - #364

Open
shunsuke-shimomura wants to merge 1 commit into
feat/346-review-surfacefrom
feat/347-record-decisions
Open

shunsuke-shimomura wants to merge 1 commit into
feat/346-review-surfacefrom
feat/347-record-decisions

Conversation

@shunsuke-shimomura

Copy link
Copy Markdown
Member

Description

Closes #347. Part of #340. Stacked on #363.

The Web UI stops being strictly read-only: a decision taken on a local view appends the record inka review
writes, through the same core operation (review::decide, from #351).

Server

  • inka serve --as <approver> (and --key-id) turns recording on and adds one route, POST /api/decisions.
    Without --as that route does not exist and every route is a GET, as before.
  • GET /api/session says who the server records as (reviewer: null on a read-only server).
  • The conditions are enforced by the router, not left to the page:
    • Identity is the server's. The approver and key id come from the command line; the request has no field
      for them.
    • Loopback only. --as with a non-loopback --host is refused at startup.
    • Own pages only. On a recording server the whole API answers only requests whose Host is one of the
      server's loopback names, which defeats a foreign name resolved to the loopback address. A decision must also
      carry the session token — 32 random bytes, new each run, readable only by a same-origin page — and, where the
      browser sends Origin, it must be this server.
    • The hash on screen. The request names the view hash that was displayed. wire::decide reads the project
      again and records only if that is still the target's hash; otherwise it answers changed (409) and writes
      nothing.
    • Append-only. One decision appends one record. PUT, PATCH and DELETE are 405 everywhere.
  • The request and response types are in inka_core::wire, and their TypeScript types are generated like the
    page's.

Page

  • The masthead says recording as <approver> or read-only.
  • Under a local view shown in full, for a target that can take a decision: a comment field, Approve and
    Decline. Decline is disabled until the comment is non-blank. Skip stays where it was.
  • After a recorded decision the page is read again and the walk moves to the next target. A changed answer
    reloads and stays on the target, saying nothing was recorded. A refusal is shown with its reason.

Test results

  • cargo test --workspace: all pass; cargo clippy --workspace --all-targets -- -D warnings: clean.
  • npm run typecheck; npm test: 21 files, 138 tests; npm run e2e: 20 passed.
  • Server tests, one per condition: no write route without --as; refusal off loopback; refusal of a missing or
    wrong token, of another site's Origin, of another port's, and of a foreign Host (for reads too); refusal of
    a stale hash with nothing written; a request that tries to bring its own approver; the record's form.
  • The end-to-end tests record a real approval and a real decline through the page, against an inka serve --as
    on a throwaway copy of the aocs fixture, so nothing is written into the repository.

Impact

  • New: inka serve --as, --key-id. A server started without them behaves as before.
  • getrandom becomes a direct dependency of inka-cli (it was already in the lock file).
  • In development the Vite proxy now addresses requests to the real server and names it as their origin, since
    the page is the dev server's and a recording server would otherwise refuse it. While it runs, the dev server
    is therefore an unguarded relay to a recording server; this is development only.

Supplementary information

The server records any decision the CLI's single-target form would: it does not refuse an approval on a
declined target, for instance. The page does not offer one; counting is eval's job, as in the CLI.

🤖 Generated with Claude Code

https://claude.ai/code/session_014DUhbQ16uSDG5M4Lt9o3NM

`inka serve --as <approver>` turns recording on. A decision taken on the
review surface appends the record `inka review` writes, through the same core
operation; without `--as` no route writes and the Web UI stays read-only.

The server enforces the conditions rather than trusting the page:

- the approver and key id are fixed at startup; a request cannot name them;
- a recording server refuses to start off a loopback address;
- the API answers only requests addressed to this server, and a decision must
  carry the session token and, where the browser states one, this server's
  origin;
- a decision names the view hash that was on screen and is refused, writing
  nothing, when the target's current hash differs.

The review surface shows who decisions are recorded as and offers approve,
decline (a reason is required) and skip under a local view shown in full, for
targets that can take a decision. After a decision the page is read again.

The end-to-end tests record against a throwaway copy of the aocs fixture.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DUhbQ16uSDG5M4Lt9o3NM
@shunsuke-shimomura shunsuke-shimomura added the enhancement ✨ New feature or request label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9f6daed and 9dc2cdb.

Files ignored due to path filters: 6

  • Cargo.lock is excluded by !**/*.lock, !**/Cargo.lock
  • web/src/generated/DecisionData.ts is excluded by !**/generated/**
  • web/src/generated/DecisionRequest.ts is excluded by !**/generated/**
  • web/src/generated/DecisionResponse.ts is excluded by !**/generated/**
  • web/src/generated/ReviewerSession.ts is excluded by !**/generated/**
  • web/src/generated/Session.ts is excluded by !**/generated/**
Files selected for processing: 22

  • README.ja.md
  • README.md
  • crate/inka-cli/Cargo.toml
  • crate/inka-cli/src/cli.rs
  • crate/inka-cli/src/main.rs
  • crate/inka-cli/src/serve.rs
  • crate/inka-cli/tests/serve.rs
  • crate/inka-core/src/wire.rs
  • web/README.md
  • web/e2e/recording-server.mjs
  • web/e2e/recording.spec.ts
  • web/playwright.config.ts
  • web/src/App.tsx
  • web/src/config.ts
  • web/src/hooks/useSession.ts
  • web/src/model/session.test.ts
  • web/src/model/session.ts
  • web/src/review/DecisionBar.tsx
  • web/src/review/Decisions.test.tsx
  • web/src/review/ReviewSurface.tsx
  • web/src/styles/app.css
  • web/vite.config.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@shunsuke-shimomura

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation 📓 Improvements or additions to documentation enhancement ✨ New feature or request sys::SE システムズエンジニアリング

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve, web: record approve and decline from the browser

1 participant