Skip to content

Add environmental footprint visualization for token usage#1108

Open
dailytrap wants to merge 2 commits into
steipete:mainfrom
dailytrap:feature/environmental-footprint
Open

Add environmental footprint visualization for token usage#1108
dailytrap wants to merge 2 commits into
steipete:mainfrom
dailytrap:feature/environmental-footprint

Conversation

@dailytrap
Copy link
Copy Markdown

Adds an environmental estimate section to the menu card, extracts shared UI, and keeps the estimates clearly labeled as rough approximations. Includes localization updates and focused tests.

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

Codex review: needs real behavior proof before merge.

Latest ClawSweeper review: 2026-05-22 12:30 UTC / May 22, 2026, 8:30 AM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
Adds environmental energy and CO2 estimate lines to token usage cost UI, tooltips, provider details, localization strings, and focused formatter/calculation tests.

Reproducibility: no. high-confidence runtime reproduction was performed in this read-only review. The review finding is source-reproducible: a one-day window can produce identical session and month environmental strings, which makes ForEach(id: \.self) non-unique.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Summary: The idea is understandable, but missing runtime proof and the duplicate-row identity bug keep the PR below merge-ready quality.

Rank-up moves:

  • Fix the ForEach identity by iterating indices or identifiable row values.
  • Add redacted real behavior proof showing the built app's cost menu or provider detail UI with the environmental rows.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Real behavior proof
Needs real behavior proof before merge: No after-fix screenshot, recording, terminal output, logs, or linked artifact shows the built menu behavior; the contributor should add redacted real behavior proof to the PR body so ClawSweeper can re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A visible macOS menu-card addition would benefit from direct UI proof after the row-identity issue is fixed. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify CodexBar cost menu shows environmental estimate rows for token usage without duplicate-row rendering or truncation.

Risk before merge

  • The new estimate constants are hard-coded and user-facing, so maintainers should decide whether this kind of rough environmental claim belongs in the core cost UI.
  • The PR has no after-fix runtime proof showing the built app's menu card or provider detail UI with the new rows.
  • The added ForEach(id: \.self) can receive duplicate environmental strings and may render or update rows unpredictably.

Maintainer options:

  1. Decide the mitigation before merge
    If maintainers want this feature, keep the estimate clearly labeled, fix row identity before merge, and require a redacted runtime screenshot or recording of the cost menu/provider detail UI.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge
The remaining blockers are contributor proof and maintainer product fit; automation could fix the row identity bug but cannot prove the contributor's runtime setup or decide whether this feature belongs in core UI.

Security
Cleared: The diff only adds app UI, formatting, localization, and tests; it does not touch dependencies, scripts, workflows, secrets, auth, or artifact execution paths.

Review findings

  • [P2] Use stable identities for environmental rows — Sources/CodexBar/EnvironmentalImpactSectionView.swift:21
Review details

Best possible solution:

If maintainers want this feature, keep the estimate clearly labeled, fix row identity before merge, and require a redacted runtime screenshot or recording of the cost menu/provider detail UI.

Do we have a high-confidence way to reproduce the issue?

No high-confidence runtime reproduction was performed in this read-only review. The review finding is source-reproducible: a one-day window can produce identical session and month environmental strings, which makes ForEach(id: \.self) non-unique.

Is this the best way to solve the issue?

No, not yet. The direction may be acceptable if maintainers want the feature, but the implementation should first use stable row identities and provide runtime proof of the visible UI.

Label changes:

  • add P3: This is a low-urgency user-facing visualization feature with limited blast radius, not a regression or availability issue.
  • add rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦐 gold shrimp, and The idea is understandable, but missing runtime proof and the duplicate-row identity bug keep the PR below merge-ready quality.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: No after-fix screenshot, recording, terminal output, logs, or linked artifact shows the built menu behavior; the contributor should add redacted real behavior proof to the PR body so ClawSweeper can re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-urgency user-facing visualization feature with limited blast radius, not a regression or availability issue.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦐 gold shrimp, and The idea is understandable, but missing runtime proof and the duplicate-row identity bug keep the PR below merge-ready quality.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: No after-fix screenshot, recording, terminal output, logs, or linked artifact shows the built menu behavior; the contributor should add redacted real behavior proof to the PR body so ClawSweeper can re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Full review comments:

  • [P2] Use stable identities for environmental rows — Sources/CodexBar/EnvironmentalImpactSectionView.swift:21
    environmentalImpactLines can contain duplicate strings when the session and one-day window estimates format the same, so ForEach(id: \.self) gives SwiftUI duplicate identities. Iterate indices or wrap rows in stable IDs so duplicate-looking lines still render and update correctly.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.84

Acceptance criteria:

  • swift test --filter EnvironmentalImpactTests
  • swift test --filter StatusMenuCostMenuCardTests
  • make check

What I checked:

  • PR diff adds environmental estimate UI: The patch adds EnvironmentalImpactSectionView and wires environmental estimate rows into token usage cost sections. (Sources/CodexBar/EnvironmentalImpactSectionView.swift:1, f22d22de5c52)
  • Current main has only cost token usage fields: Current main's TokenUsageSection contains only session, month, hint, error, and copy text fields, so the requested environmental visualization is not already implemented. (Sources/CodexBar/MenuCardView.swift:83, 097d502afb29)
  • Duplicate SwiftUI identity risk: The new view renders rows with ForEach(self.lines, id: \.self), but the proposed session and month strings can be identical for a one-day window, giving duplicate row IDs. (Sources/CodexBar/EnvironmentalImpactSectionView.swift:21, f22d22de5c52)
  • No real behavior proof in discussion: The PR body describes tests and localization updates, and the provided GitHub context has zero comments or review comments with screenshots, recordings, terminal output, logs, or linked artifacts. (f22d22de5c52)
  • Area history points to current cost UI owner: Blame for the current cost model and cost menu item code attributes the relevant lines to Peter Steinberger in the v0.28.0 appcast commit present in this checkout. (Sources/CodexBar/MenuCardView+Costs.swift:20, 2db843a4600f)
  • Recent adjacent menu-card change: The only recent non-release history touching MenuCardView.swift in this checkout is Misty's Alibaba Token Plan provider change. (Sources/CodexBar/MenuCardView.swift, b2bc921ab8b8)

Likely related people:

  • Peter Steinberger: Current blame for token usage cost model, cost menu tooltip/subtitle helpers, and related localization in this checkout points to Peter Steinberger. (role: current cost UI area contributor; confidence: high; commits: 2db843a4600f, 097d502afb29; files: Sources/CodexBar/MenuCardView+Costs.swift, Sources/CodexBar/StatusItemController+CostMenuCard.swift, Sources/CodexBar/MenuCardView.swift)
  • Misty: Recent history shows Misty changed MenuCardView.swift for the Alibaba Token Plan provider shortly before this PR. (role: recent adjacent contributor; confidence: medium; commits: b2bc921ab8b8; files: Sources/CodexBar/MenuCardView.swift)
  • narallee: Recent history shows narallee updated the Simplified Chinese localization file that this PR also touches. (role: localization adjacent contributor; confidence: medium; commits: 573652ae89f9; files: Sources/CodexBar/Resources/zh-Hans.lproj/Localizable.strings)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 097d502afb29.

Copy link
Copy Markdown

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

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: f22d22de5c

ℹ️ 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 on lines +65 to +69
"environmental_impact_energy_today",
UsageFormatter.formatEnergy(impact.energyKWh),
impact.smartphoneCharges,
impact.kettleBoils)
co2SessionLine = L(
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 Preserve Bedrock billing-day semantics in eco session text

For .bedrock, sessionTokens represents the latest billing day (not necessarily today), but this new branch always formats the session eco line with the environmental_impact_*_today copy. That makes the environmental row claim “Today” even when the data is from an older day, which is a user-visible accuracy regression specific to Bedrock and inconsistent with the existing sessionLine logic that already uses a billing-day label.

Useful? React with 👍 / 👎.

@steipete
Copy link
Copy Markdown
Owner

I'd love to see screenshots + sources for the calculation. Not completely opposed, but must be correct.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 22, 2026
@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

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

Labels

rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants