Skip to content

Fix WorkBuddy travel and first-Buddy onboarding - #24

Merged
maiphucgiang merged 6 commits into
mainfrom
fix/workbuddy-travel-protocol
Sep 16, 2026
Merged

maiphucgiang merged 6 commits into
mainfrom
fix/workbuddy-travel-protocol

Conversation

@maiphucgiang

Copy link
Copy Markdown
Owner

Summary

  • Align travel responses, location configuration and post-write checks with the official WorkBuddy protocol.
  • Add one-checkbox first-Buddy consent, optional environment preauthorization, durable one-shot onboarding and per-account daily warnings. first_buddy performs a real bounded conversation without the generic task-acceptance endpoint.
  • Preserve account isolation and non-replayable writes; update WebUI diagnostics, bilingual docs and concise English comments.

Validation

  • All 48 backend test scripts passed using the CI entrypoints.
  • WebUI: 122 tests across 14 files; formatting, lint, types and build passed.
  • Live verification: one onboarding conversation, official task completion, Buddy adoption and confirmed departure.
  • Version unchanged; global preauthorization defaults to off.

Awaiting CI and current-head review; no merge requested.

Accept empty successful write receipts, select current upstream locations, and verify travel state after writes without replaying uncertain POSTs. Expose safe diagnostics in the management UI and document partial outcomes.

Keep handwritten comments and docstrings concise and English without changing unrelated executable code or configuration semantics.

Validated: 55 targeted backend tests and 86 subtests; 17 frontend tests; frontend formatting, lint, type checks and build; 80-file comment-only AST comparison. No version changes or live account actions.
Persist account-scoped consent and one-shot onboarding conversations, then verify official task completion before adoption and travel. Support default-off environment preauthorization, daily warnings and safe audit details.

Handle first_buddy without the generic task-acceptance endpoint and resume legacy acceptance-only records without replaying conversations. Synchronize confirmation UI, bilingual docs and deployment examples.

Validation: all CI-style backend test scripts, 122 WebUI tests, frontend checks/build, and live onboarding through confirmed departure.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @maiphucgiang, your pull request is larger than the review limit of 500,000 diff characters

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-16T03:15:48.966472Z 6ea2c79 New commits
🔒 Security Review Completed 2026-09-16T01:51:26.662279Z 26bf166 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26bf1667fe

ℹ️ 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".

Comment thread app/control_store.py
@maiphucgiang

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b7f144933

ℹ️ 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".

Comment thread app/buddy_task.py Outdated
Comment on lines +142 to +145
if not can_write():
return stop("buddy_task_changed")
if not selector(model["id"]):
return stop("buddy_task_no_model")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Release unsent chat reservations when final checks fail

If the account/travel setting or selected model becomes unavailable between reserve_buddy_task() and these final checks, the function returns without calling _chat, but the reservation has already persisted chat_started=1. Every later sweep then takes the previous["chat_started"] path and reports buddy_task_unconfirmed forever, so re-enabling the account or restoring the model cannot resume onboarding even though no conversation was sent. Record this as definitely unsent or release the reservation before returning from either check.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a822c2dd61

ℹ️ 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".

Comment thread app/credential_actions.py
Comment on lines 106 to +108
result = travel.perform(gateway._bearer_token(headers), gateway.profile_for_headers(headers),
read_only=action == "travel-status", can_write=can_write)
read_only=action == "travel-status", can_write=can_write,
buddy_context=gateway._buddy_context(entry, headers, consent_revision))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck account enablement during onboarding

Passing this can_write callback into the new onboarding flow does not actually detect an account being disabled after the action starts: for manual actions not automatic short-circuits the policy check, while the automatic branch checks only auto_travel, not credential_enabled. If an administrator disables the account while task verification or another upstream request is in progress, subsequent agreement, first-Buddy, and departure writes can still run; include the current enabled state in every can_write evaluation.

Useful? React with 👍 / 👎.

Comment thread app/travel.py
Comment on lines +197 to +200
result.update(_status(_request(client, token, "status")))
if result["state"] == "idle":
result.update(message=prefix + "派遣已确认,但状态仍为空闲;请先查询核验,勿重复派出")
return result

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reserve confirmed departures before permitting another dispatch

When the departure POST succeeds but the immediate read still reports idle, this path returns departed=true and ok=false without creating any reservation that a later invocation consults. An immediate manual retry or the next automatic sweep will again see idle/limit-false and send another /depart POST, despite the message saying not to repeat the confirmed write. Persist and check the uncertain confirmed departure until a read reconciles it.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a84c3d4c82

ℹ️ 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".

Comment thread app/buddy.py
return stop("buddy_retry_later")
if not event("authorization_used", "success"):
return stop("buddy_storage_error")
if not agreed:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record agreements that were already accepted

When the agreement read returns agreed=true—for example, because the user accepted it previously—this branch is skipped while result["agreement_accepted"] remains false. A successful first-Buddy claim is therefore checkpointed with agreed=0, and both the immediate response and any later reconciliation incorrectly report that the confirmed official agreement was not accepted. Initialize agreement_accepted from the validated agreed value before conditionally posting the agreement.

Useful? React with 👍 / 👎.

@maiphucgiang
maiphucgiang merged commit ddaac0a into main Sep 16, 2026
8 of 9 checks passed
@maiphucgiang maiphucgiang mentioned this pull request Sep 16, 2026
@maiphucgiang
maiphucgiang deleted the fix/workbuddy-travel-protocol branch September 16, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant