Chapter 6
Translating the experience into production behavior
Define service outcomes, preserve user work, and implement an assignment flow that handles stale state and uncertain results.
The prototype assumes assignment is either successful or rejected. A service engineer adds another possibility: the server may record the assignment while its response is lost. If the interface treats every transport error as a failed mutation, it can encourage an unnecessary second attempt.
The implementation decision is how to represent what the system actually knows. Begin with the outcome contract, then build the behavior around it.
Agree on the service boundary
The service owns current authorization, record status, and the assignment write. The browser presents what it last learned and explains the next action. An enabled button expresses the interface’s current understanding; it cannot authorize a mutation.
The team needs to distinguish a confirmed save, a known rejection, and an unconfirmed outcome. It also needs a way to read the latest recorded state. For Casework, the contract includes a record version so the service can reject a write made against an older case state.
This sketch describes the concepts; it is not a complete API definition:
type AssignmentOutcome =
| { kind: 'saved'; caseVersion: number; assignedTeam: string }
| { kind: 'rejected'; reason: 'forbidden' | 'closed' | 'changed' }
| { kind: 'unconfirmed' };
Agree on when a rejection guarantees that no write occurred. Check which failures can leave the outcome unknown. For consequential mutations, discuss idempotency and an operation-status lookup with the service team. A UI-only duplicate-submit guard cannot protect against retries from another tab or client.
Inspect the runnable example
Open the assignment review example and choose a specialist team. The scenario control can produce a successful save, an already closed case, a case that changes during submission, revoked permission, or a lost response after saving.
The example is a small browser application with three files: index.html, app.js, and service.js. The service is simulated in browser memory. It provides predictable behavior for learning and checks; it provides no real authorization, persistent storage, or production integration. Reloading resets it.
For the lost-response scenario, choose a team and submit. The simulated service saves the assignment, then throws a transport error. The interface explains that it could not confirm the result. Choose Check latest case to see the recorded team. No automatic retry occurs.
Make uncertainty a first-class state
The assignment flow uses a small set of states:
| State | Available behavior |
|---|---|
| Ready | Choose a team and submit if the latest case is assignable |
| Saving | Keep the chosen team visible; prevent another submission |
| Rejected | Explain the known outcome and retain the choice where useful |
| Unconfirmed | Explain uncertainty and check the latest case before another write |
| Checking | Read the current case; do not issue a mutation |
| Confirmed | Show the recorded assignment and allow the next appropriate task |
The example has only one administrator and one assignment at a time. Its read-back resolves the supplied lost-response scenario. In a real multi-user system, a latest-state read alone may not prove which operation produced that state. Another administrator may have changed the assignment again. Where that distinction matters, track a durable operation identifier and reconcile the operation itself.
Preserve useful work and update facts carefully
Keep the user’s selected team when a known rejection occurs, unless that selection has become invalid. Display the latest case status separately from the proposed assignment so people can distinguish their intention from the recorded result.
During an in-flight request, disable the controls that would change its meaning. This makes the small example easier to reason about. A more flexible product may allow continued editing, but it must then associate each response with the operation and inputs it belongs to. Review stale responses explicitly; a slow earlier request should not overwrite a later result.
Read back current state after a version conflict. Do not quietly change the version and repeat the mutation. The administrator should have an opportunity to understand what changed before deciding whether the action is still appropriate.
Integrate a bounded slice
In a real application, keep the existing shell, navigation, components, and service conventions. Add the smallest complete workflow that tests the chosen product direction. A new global state system or shared component abstraction needs its own justification.
Translate the same state model into your framework. Keep service results distinct from view state, validate external data at the boundary according to your project’s conventions, and use the existing error and logging facilities. The book’s example isolates decisions; it does not prescribe a production architecture.
Practice: change the contract and the interface
Run the example’s scenarios and record what the interface knows at each stage. Then add one controlled failure, such as an unreadable latest-case response. Make the interface retain uncertainty and offer an appropriate next step rather than claiming reconciliation succeeded.
For your own application, implement a bounded equivalent using its service client. Document permission, version, rejection, and uncertain-outcome behavior with the service owner. Mark any unverified assumptions and distinguish simulated checks from integration evidence.
Review your work
Demonstrate a successful assignment, a known rejection, a stale-record conflict, and an uncertain result. Show that the interface avoids a second write during an unresolved operation and preserves relevant user input. Explain where authorization occurs and how your design would change for multiple concurrent users.
The next chapter defines the evidence needed before releasing the workflow to actual users.
Found an error? Report it.