Repository navigation
Fix M365 review placement and add editable draft lifecycle #1754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Paul Lizer (paullizer)
merged 3 commits into
microsoft:paullizer-react-v2-ui
from
paullizer:paullizer-email-review-flow
Oct 11, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
239 changes: 227 additions & 12 deletions
239
application/single_app/functions_m365_pending_delivery.py
Large diffs are not rendered by default.
Oops, something went wrong.
503 changes: 503 additions & 0 deletions
503
application/single_app/functions_m365_pending_review.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # functions_m365_review_history.py | ||
| """Bounded owner-partitioned review history, separate from delivery receipts.""" | ||
|
|
||
| from copy import deepcopy | ||
| import json | ||
|
|
||
| from azure.cosmos.exceptions import CosmosResourceNotFoundError | ||
|
|
||
| from cosmos_document_utils import normalize_cosmos_document | ||
|
|
||
|
|
||
| MAX_REVIEW_HISTORY_ITEMS = 40 | ||
| MAX_REVIEW_HISTORY_BYTES = 1600000 | ||
|
|
||
|
|
||
| def history_id(action_id): | ||
| return f"pending-review:{action_id}" | ||
|
|
||
|
|
||
| def read_review_history(container, action): | ||
| try: | ||
| record = normalize_cosmos_document(container.read_item( | ||
| history_id(action["id"]), partition_key=action["user_id"], | ||
| )) | ||
| except CosmosResourceNotFoundError: | ||
| return None | ||
| if record.get("user_id") != action["user_id"] or record.get("action_id") != action["id"]: | ||
| raise PermissionError("Review history belongs to another action.") | ||
| return record | ||
|
|
||
|
|
||
| def commit_review_history(container, action, updated, entry): | ||
| """Commit one action revision and its history in one owner-partition transaction.""" | ||
| existing = read_review_history(container, action) | ||
| record = deepcopy(existing) if existing else { | ||
| "id": history_id(action["id"]), "user_id": action["user_id"], | ||
| "action_id": action["id"], "conversation_id": action.get("conversation_id", ""), | ||
| "type": "msgraph_pending_review_history", "items": [], | ||
| } | ||
| items = record["items"] | ||
| if entry.get("assist_turn_id"): | ||
| for item in items: | ||
| if item["id"] == entry["assist_turn_id"] and item["kind"] == "assist": | ||
| item.update(saved=True, applied=True) | ||
| items.append(deepcopy(entry)) | ||
| while len(items) > MAX_REVIEW_HISTORY_ITEMS or len(json.dumps(items, ensure_ascii=True).encode()) > MAX_REVIEW_HISTORY_BYTES: | ||
| items.pop(0) | ||
| record["items"] = items | ||
| record["updated_at"] = entry["created_at"] | ||
| operations = [ | ||
| ("replace", (action["id"], updated), {"if_match_etag": action["_etag"]}), | ||
| ("replace", (record["id"], record), {"if_match_etag": existing["_etag"]}) | ||
| if existing else ("create", (record,)), | ||
| ] | ||
| container.execute_item_batch(batch_operations=operations, partition_key=action["user_id"]) | ||
| return normalize_cosmos_document(container.read_item(action["id"], partition_key=action["user_id"])) | ||
|
|
||
|
|
||
| def clear_review_history(container, action): | ||
| """Remove editable material on terminal delivery without removing its receipt.""" | ||
| existing = read_review_history(container, action) | ||
| if existing is None: | ||
| return | ||
| # The terminal action is authoritative even if a concurrent history request lost its race. | ||
| container.delete_item(existing["id"], partition_key=action["user_id"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.