Repository navigation
fix(hub): show an approval decision once instead of as raw JSON #130
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
TheGreatAxios
merged 2 commits into
main
from
cl-12071-show-an-approval-decision-once-instead-of-as-raw-json-from
Nov 4, 2026
Merged
Changes from all commits
Commits
Show all changes
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { afterEach, expect, test } from "bun:test"; | ||
| import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { $ } from "bun"; | ||
| import { readDurableConversationTurns } from "./conversation-turns.ts"; | ||
|
|
||
| const person = "b65b0e2f4c4a444db11b7321dc413964@sunny-harbor-panda.localhost"; | ||
| const dirs: string[] = []; | ||
|
|
||
| afterEach(async () => { | ||
| await Promise.all( | ||
| dirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })), | ||
| ); | ||
| }); | ||
|
|
||
| // A run repo whose committed coordinator mirror holds these inbound messages, as Interchange stores them. | ||
| async function runRepo(inbound: { from: string; text: string }[]) { | ||
| const dir = await mkdtemp(join(tmpdir(), "sb-conversation-turns-")); | ||
| dirs.push(dir); | ||
| const wal = join(dir, "agent-state", "coordinate", "wal", "0"); | ||
| await mkdir(wal, { recursive: true }); | ||
| const turns = inbound.map(({ from, text }, at) => ({ | ||
| role: "user", | ||
| content: [{ type: "text", text: `[From: ${from}]\n\n${text}` }], | ||
| timestamp: at + 1, | ||
| })); | ||
| const metadata = { | ||
| pendingOperations: [], | ||
| tokenUsage: { | ||
| input: 0, | ||
| output: 0, | ||
| cacheRead: 0, | ||
| cacheWrite: 0, | ||
| thinking: 0, | ||
| }, | ||
| connectorState: null, | ||
| }; | ||
| await writeFile( | ||
| join(wal, "0.json"), | ||
| JSON.stringify({ seq: 0, turns, metadata }), | ||
| ); | ||
| const env = { | ||
| ...process.env, | ||
| GIT_AUTHOR_NAME: "test", | ||
| GIT_AUTHOR_EMAIL: "test@example.com", | ||
| GIT_COMMITTER_NAME: "test", | ||
| GIT_COMMITTER_EMAIL: "test@example.com", | ||
| }; | ||
| await $`git init -q -b main ${dir}`.env(env); | ||
| await $`git -C ${dir} add -A`.env(env); | ||
| await $`git -C ${dir} -c commit.gpgsign=false commit -q -m mirror`.env(env); | ||
| return dir; | ||
| } | ||
|
|
||
| const decisions = () => | ||
| runRepo([ | ||
| { from: person, text: "Sure" }, | ||
| { from: "signal@local", text: JSON.stringify({ outcome: "approved" }) }, | ||
| { from: "signal@local", text: JSON.stringify({ outcome: "rejected" }) }, | ||
| { | ||
| from: "signal@local", | ||
| text: JSON.stringify({ outcome: "rejected", message: "Keep it free" }), | ||
| }, | ||
| { | ||
| from: "signal@local", | ||
| text: JSON.stringify({ outcome: "approved", message: " " }), | ||
| }, | ||
| ]); | ||
|
|
||
| const personTexts = async ( | ||
| dir: string, | ||
| approvalDecisions: "note" | "decision", | ||
| ) => | ||
| ( | ||
| await readDurableConversationTurns({ | ||
| repoStore: { getRepoDir: () => dir }, | ||
| address: | ||
| "run_04ba732b8686649f77a2797393bafbc5@sunny-harbor-panda.localhost", | ||
| approvalDecisions, | ||
| }) | ||
| ).map(({ role, text }) => ({ role, text })); | ||
|
|
||
| test("page turns keep only the note sent with an approval decision", async () => { | ||
| expect(await personTexts(await decisions(), "note")).toEqual([ | ||
| { role: "person", text: "Sure" }, | ||
| { role: "person", text: "Keep it free" }, | ||
| ]); | ||
| }); | ||
|
|
||
| test("resume turns read each approval decision as a plain line", async () => { | ||
| expect(await personTexts(await decisions(), "decision")).toEqual([ | ||
| { role: "person", text: "Sure" }, | ||
| { role: "person", text: "Approved a request." }, | ||
| { role: "person", text: "Rejected a request." }, | ||
| { role: "person", text: "Rejected a request: Keep it free" }, | ||
| { role: "person", text: "Approved a request." }, | ||
| ]); | ||
| }); |
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
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.