Skip to content

Commit fdae4d1

Browse files
committed
ci: rebuild and verify welcome gutter successor
1 parent 2a7f33d commit fdae4d1

1 file changed

Lines changed: 149 additions & 0 deletions

File tree

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Rebuild and verify welcome gutter successor
2+
3+
on:
4+
push:
5+
branches:
6+
- successor/welcome-composer-gutter-current-v2
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
rebuild:
13+
if: github.actor == 'twoimo'
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: successor/welcome-composer-gutter-current-v2
19+
fetch-depth: 0
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
22+
- name: Rebuild reviewed change on current upstream dev
23+
shell: bash
24+
run: |
25+
git config user.name "twoimo"
26+
git config user.email "32544727+twoimo@users.noreply.github.com"
27+
git remote add upstream https://github.com/Yeachan-Heo/gajae-code.git || true
28+
git fetch --no-tags upstream dev
29+
git reset --hard upstream/dev
30+
python3 - <<'PY'
31+
from pathlib import Path
32+
33+
welcome_path = Path('packages/coding-agent/src/modes/components/welcome.ts')
34+
welcome = welcome_path.read_text()
35+
replacements = [
36+
('\tchangelogMarkdown?: string;\n\tcollapseChangelog?: boolean;',
37+
'\tchangelogMarkdown?: string;\n\trightGutterWidth?: number;\n\tcollapseChangelog?: boolean;'),
38+
('\t\tconst boxWidth = Math.max(0, termWidth);',
39+
'\t\tconst rightGutterWidth = this.#rightGutterWidth(termWidth);\n\t\tconst boxWidth = Math.max(0, termWidth - rightGutterWidth);'),
40+
('\t\tif (outputRows === 1) {\n\t\t\treturn lines;\n\t\t}',
41+
'\t\tif (outputRows === 1) {\n\t\t\treturn this.#withRightGutter(lines, rightGutterWidth);\n\t\t}'),
42+
('\t\treturn lines;\n\t}\n\n\t/** Center text within a given width */',
43+
'\t\treturn this.#withRightGutter(lines, rightGutterWidth);\n\t}\n\n\t/** Center text within a given width */'),
44+
('\t#targetRows(termWidth: number): number | undefined {',
45+
'''\t#rightGutterWidth(termWidth: number): number {
46+
\t\tconst configured = this.options.rightGutterWidth ?? 0;
47+
\t\tif (!Number.isFinite(configured) || configured <= 0) return 0;
48+
\t\tconst gutterWidth = Math.floor(configured);
49+
\t\treturn Math.min(gutterWidth, Math.max(0, termWidth - 4));
50+
\t}
51+
52+
\t#withRightGutter(lines: string[], rightGutterWidth: number): string[] {
53+
\t\tif (rightGutterWidth <= 0) return lines;
54+
\t\tconst gutter = padding(rightGutterWidth);
55+
\t\treturn lines.map(line => line + gutter);
56+
\t}
57+
58+
\t#targetRows(termWidth: number): number | undefined {'''),
59+
]
60+
for old, new in replacements:
61+
if old not in welcome:
62+
raise SystemExit(f'welcome anchor missing: {old[:80]}')
63+
welcome = welcome.replace(old, new, 1)
64+
welcome_path.write_text(welcome)
65+
66+
mode_path = Path('packages/coding-agent/src/modes/interactive-mode.ts')
67+
mode = mode_path.read_text()
68+
replacements = [
69+
('const WELCOME_RESERVED_CONTAINER_CHILD_LIMIT = 8;\n',
70+
'const WELCOME_RESERVED_CONTAINER_CHILD_LIMIT = 8;\nconst COMPOSER_RIGHT_GUTTER_WIDTH = 1;\n'),
71+
('\teditor.setRightGutterWidth(1);',
72+
'\teditor.setRightGutterWidth(COMPOSER_RIGHT_GUTTER_WIDTH);'),
73+
('\t\t\t\t\tchangelogMarkdown: this.#changelogMarkdown,\n\t\t\t\t\tcollapseChangelog:',
74+
'\t\t\t\t\tchangelogMarkdown: this.#changelogMarkdown,\n\t\t\t\t\trightGutterWidth: COMPOSER_RIGHT_GUTTER_WIDTH,\n\t\t\t\t\tcollapseChangelog:'),
75+
]
76+
for old, new in replacements:
77+
if old not in mode:
78+
raise SystemExit(f'interactive-mode anchor missing: {old[:80]}')
79+
mode = mode.replace(old, new, 1)
80+
mode_path.write_text(mode)
81+
82+
test_path = Path('packages/coding-agent/test/welcome-viewport.test.ts')
83+
tests = test_path.read_text()
84+
marker = '\tit("renders the build label from metadata instead of defaulting to dev", () => {'
85+
regression = '''\tit("reserves the composer gutter for normal and one-row welcome layouts", () => {
86+
\t\tconst full = new WelcomeComponent("1.2.3", "test-model", "test-provider", [], [], "ascii", {
87+
\t\t\trightGutterWidth: 1,
88+
\t\t});
89+
\t\tconst fullLines = full.render(100).map(stripRenderControls);
90+
\t\texpect(fullLines.length).toBeGreaterThan(0);
91+
\t\tfor (const line of fullLines) {
92+
\t\t\texpect(visibleWidth(line)).toBe(100);
93+
\t\t\texpect(line.endsWith(" ")).toBe(true);
94+
\t\t\texpect(visibleWidth(line.trimEnd())).toBe(99);
95+
\t\t}
96+
97+
\t\tconst oneRow = new WelcomeComponent("1.2.3", "test-model", "test-provider", [], [], "ascii", {
98+
\t\t\trightGutterWidth: 1,
99+
\t\t\tgetViewportRows: () => 1,
100+
\t\t\tgetReservedBottomRows: () => 0,
101+
\t\t});
102+
\t\tconst [line] = oneRow.render(100).map(stripRenderControls);
103+
\t\texpect(line).toBeDefined();
104+
\t\texpect(visibleWidth(line!)).toBe(100);
105+
\t\texpect(line!.endsWith(" ")).toBe(true);
106+
\t\texpect(visibleWidth(line!.trimEnd())).toBe(99);
107+
\t});
108+
109+
'''
110+
if tests.count(marker) != 1:
111+
raise SystemExit('welcome test insertion anchor missing')
112+
test_path.write_text(tests.replace(marker, regression + marker, 1))
113+
114+
changelog_path = Path('packages/coding-agent/CHANGELOG.md')
115+
changelog = changelog_path.read_text()
116+
entry = '- Aligned the startup GJC Forge splash border with the composer trailing gutter, including the one-row constrained fallback.\n'
117+
if entry not in changelog:
118+
marker = '### Fixed\n\n'
119+
if marker not in changelog:
120+
raise SystemExit('changelog Fixed anchor missing')
121+
changelog = changelog.replace(marker, marker + entry, 1)
122+
changelog_path.write_text(changelog)
123+
PY
124+
125+
- uses: oven-sh/setup-bun@v2
126+
with:
127+
bun-version: '1.3'
128+
129+
- name: Install, format, and verify
130+
run: |
131+
bun install --frozen-lockfile
132+
bunx biome check --write \
133+
packages/coding-agent/src/modes/components/welcome.ts \
134+
packages/coding-agent/src/modes/interactive-mode.ts \
135+
packages/coding-agent/test/welcome-viewport.test.ts
136+
bun test --timeout 30000 packages/coding-agent/test/welcome-viewport.test.ts
137+
bun test --timeout 30000 packages/coding-agent/test/interactive-mode-editor-component.test.ts --test-name-pattern "welcome|viewport-bound|composer"
138+
bun --cwd=packages/coding-agent run check
139+
140+
- name: Publish verified clean successor
141+
shell: bash
142+
run: |
143+
git add \
144+
packages/coding-agent/CHANGELOG.md \
145+
packages/coding-agent/src/modes/components/welcome.ts \
146+
packages/coding-agent/src/modes/interactive-mode.ts \
147+
packages/coding-agent/test/welcome-viewport.test.ts
148+
git commit -m "fix(coding-agent): align welcome and composer gutters"
149+
git push --force origin HEAD:successor/welcome-composer-gutter-current-v2

0 commit comments

Comments
 (0)