mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-01 16:59:32 +01:00
fix(story-mode): a push in its own command is not a commit
From review round 6: commit, then push as a second command (the most common way to ship) drew as "Claude saves the work in 2 commits and uploads it." for one commit, and the commit's message was dropped. A command's `commits` was only recorded above one, and the save panel then counted every save command as one. It is now recorded whenever a command commits and is the only thing counted: "Claude saves the work and uploads it: "feat: add mode()"." A push of earlier commits reads "Claude uploads the work." Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c36700a9c0
commit
c5ee5aaf0a
4 files changed
+33
-8
No files matched your search
+14
-6
@@ -78,7 +78,7 @@ interface ReducedInput {
|
|||||||
ships?: 'pr' | 'push';
|
ships?: 'pr' | 'push';
|
||||||
/** The segment of a Bash one-liner that decided its intent. */
|
/** The segment of a Bash one-liner that decided its intent. */
|
||||||
headline?: string;
|
headline?: string;
|
||||||
/** How many commits a save makes, when more than one. */
|
/** How many commits the command makes (`git commit` segments), when any. */
|
||||||
commits?: number;
|
commits?: number;
|
||||||
/** The first commit's message, when the command spells it out. */
|
/** The first commit's message, when the command spells it out. */
|
||||||
subject?: string;
|
subject?: string;
|
||||||
@@ -879,7 +879,8 @@ function reduceInput(name: string, input: unknown, cwd?: string): ReducedInput {
|
|||||||
if (heads.some((h) => /^gh pr create\b/.test(h))) input.ships = 'pr';
|
if (heads.some((h) => /^gh pr create\b/.test(h))) input.ships = 'pr';
|
||||||
else if (heads.some((h) => /^git push\b/.test(h))) input.ships = 'push';
|
else if (heads.some((h) => /^git push\b/.test(h))) input.ships = 'push';
|
||||||
const commits = heads.filter((h) => /^git commit\b/.test(h)).length;
|
const commits = heads.filter((h) => /^git commit\b/.test(h)).length;
|
||||||
if (commits > 1 || (commits && intent !== 'save')) input.commits = commits;
|
// Counted on every command that commits: a save can also be a push or a tag that makes none.
|
||||||
|
if (commits) input.commits = commits;
|
||||||
if (commits) {
|
if (commits) {
|
||||||
const subject = commitSubject(full);
|
const subject = commitSubject(full);
|
||||||
if (subject) input.subject = subject;
|
if (subject) input.subject = subject;
|
||||||
@@ -1964,8 +1965,9 @@ function montageSummary(evs: StoryEvent[]): string {
|
|||||||
if (evs.some((e) => e.intent === 'web')) parts.push('checks the web');
|
if (evs.some((e) => e.intent === 'web')) parts.push('checks the web');
|
||||||
if (evs.some((e) => e.intent === 'edit')) parts.push('changes files');
|
if (evs.some((e) => e.intent === 'edit')) parts.push('changes files');
|
||||||
if (evs.some((e) => e.intent === 'test' || e.intent === 'build')) parts.push('runs checks');
|
if (evs.some((e) => e.intent === 'test' || e.intent === 'build')) parts.push('runs checks');
|
||||||
const commits = evs.reduce((n, e) => n + (e.commits ?? (e.intent === 'save' ? 1 : 0)), 0);
|
const commits = evs.reduce((n, e) => n + (e.commits ?? 0), 0);
|
||||||
if (commits) parts.push(commits > 1 ? `saves the work in ${commits} commits` : 'saves the work');
|
if (commits || evs.some((e) => e.intent === 'save'))
|
||||||
|
parts.push(commits > 1 ? `saves the work in ${commits} commits` : 'saves the work');
|
||||||
return parts.length ? parts.join(', ') : 'a few more steps';
|
return parts.length ? parts.join(', ') : 'a few more steps';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2238,13 +2240,17 @@ function decorate(draft: DraftPanel, events: StoryEvent[], turn: StoryTurn, inde
|
|||||||
? /\[new branch\]|\S+\.\.\S+\s+\S+\s+->|\bset up to track\b|Everything up-to-date/.test(out)
|
? /\[new branch\]|\S+\.\.\S+\s+\S+\s+->|\bset up to track\b|Everything up-to-date/.test(out)
|
||||||
: /^\[[^\]\n]+ [0-9a-f]{7,}\]/m.test(out));
|
: /^\[[^\]\n]+ [0-9a-f]{7,}\]/m.test(out));
|
||||||
if (savedAnyway) panel.ok = true;
|
if (savedAnyway) panel.ok = true;
|
||||||
const commits = evs.reduce((n, e) => n + (e.commits ?? (e.intent === 'save' ? 1 : 0)), 0);
|
const commits = evs.reduce((n, e) => n + (e.commits ?? 0), 0);
|
||||||
const inCommits = commits > 1 ? ` in ${commits} commits` : '';
|
const inCommits = commits > 1 ? ` in ${commits} commits` : '';
|
||||||
|
// A push of commits made earlier: nothing is saved here, only uploaded.
|
||||||
|
const uploadOnly = ships === 'push' && !commits;
|
||||||
// One commit: its message says what was saved.
|
// One commit: its message says what was saved.
|
||||||
const subject = commits === 1 ? evs.find((e) => e.subject)?.subject : undefined;
|
const subject = commits === 1 ? evs.find((e) => e.subject)?.subject : undefined;
|
||||||
const said = subject ? `: "${clip(subject, 60).replace(/[.]$/, '')}"` : '';
|
const said = subject ? `: "${clip(subject, 60).replace(/[.]$/, '')}"` : '';
|
||||||
story = savedAnyway
|
story = savedAnyway
|
||||||
? ships === 'push'
|
? uploadOnly
|
||||||
|
? 'Claude uploads the work, but a step after that fails.'
|
||||||
|
: ships === 'push'
|
||||||
? `Claude saves the work${inCommits} and uploads it, but a step after that fails.`
|
? `Claude saves the work${inCommits} and uploads it, but a step after that fails.`
|
||||||
: `Claude saves the work${inCommits}, but a step after that fails.`
|
: `Claude saves the work${inCommits}, but a step after that fails.`
|
||||||
: panel.ok === false
|
: panel.ok === false
|
||||||
@@ -2255,6 +2261,8 @@ function decorate(draft: DraftPanel, events: StoryEvent[], turn: StoryTurn, inde
|
|||||||
: 'Claude tries to save the work, and the command fails.'
|
: 'Claude tries to save the work, and the command fails.'
|
||||||
: ships === 'pr'
|
: ships === 'pr'
|
||||||
? 'Claude opens a pull request.'
|
? 'Claude opens a pull request.'
|
||||||
|
: uploadOnly
|
||||||
|
? 'Claude uploads the work.'
|
||||||
: ships === 'push'
|
: ships === 'push'
|
||||||
? `Claude saves the work${inCommits} and uploads it${said}.`
|
? `Claude saves the work${inCommits} and uploads it${said}.`
|
||||||
: `Claude saves the work${inCommits}${said}.`;
|
: `Claude saves the work${inCommits}${said}.`;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
{
|
{
|
||||||
"kind": "save",
|
"kind": "save",
|
||||||
"ok": true,
|
"ok": true,
|
||||||
"story": "Claude saves the work in 2 commits and uploads it, but a step after that fails.",
|
"story": "Claude saves the work and uploads it, but a step after that fails.",
|
||||||
"director": "git commit -q -F - · git push -u origin main · 1 error",
|
"director": "git commit -q -F - · git push -u origin main · 1 error",
|
||||||
"balloon": null,
|
"balloon": null,
|
||||||
"tests": null,
|
"tests": null,
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ describe('Story Mode on real sessions', () => {
|
|||||||
it('a push that went through, with a step after it that failed, says both', () => {
|
it('a push that went through, with a step after it that failed, says both', () => {
|
||||||
expect(panel('question-tests-first-push', 0, 'save')).toMatchObject({
|
expect(panel('question-tests-first-push', 0, 'save')).toMatchObject({
|
||||||
ok: true,
|
ok: true,
|
||||||
story: 'Claude saves the work in 2 commits and uploads it, but a step after that fails.',
|
// One commit, then a push in a command of its own: one commit, not two.
|
||||||
|
story: 'Claude saves the work and uploads it, but a step after that fails.',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -950,6 +950,22 @@ describe('buildStoryPage', () => {
|
|||||||
expect(page.filesChanged).toBe(2);
|
expect(page.filesChanged).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('a commit then a push in its own command is one commit, named; a push alone only uploads', () => {
|
||||||
|
const save = (lines: unknown[]) => pageOf(lines).panels.find((p) => p.kind === 'save')!.caption.story;
|
||||||
|
expect(
|
||||||
|
save([
|
||||||
|
prompt('ship it'),
|
||||||
|
...bash('b1', 'git commit -qm "feat: add mode()"', 'Commit', ''),
|
||||||
|
...bash('b2', 'git push origin main', 'Push', 'To ./origin.git\n f80bb31..3e0fb80 main -> main'),
|
||||||
|
end(1000),
|
||||||
|
])
|
||||||
|
).toBe('Claude saves the work and uploads it: "feat: add mode()".');
|
||||||
|
expect(save([prompt('push'), ...bash('b1', 'git push', 'Push', 'Everything up-to-date'), end(1000)])).toBe(
|
||||||
|
'Claude uploads the work.'
|
||||||
|
);
|
||||||
|
expect(pageOf([prompt('c'), ...bash('b1', 'git commit -qm x', 'Commit', ''), end(1000)]).events[1].commits).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('a python or node script fed by a here-document: the files it opens for writing, never guessed', () => {
|
it('a python or node script fed by a here-document: the files it opens for writing, never guessed', () => {
|
||||||
const files = (command: string) => heredocWrites(command, '/w').map((d) => d.file);
|
const files = (command: string) => heredocWrites(command, '/w').map((d) => d.file);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
Reference in new issue
Block a user