-
Notifications
You must be signed in to change notification settings - Fork 229
[3/4] feat(scm): add Source Control button for commit message generation #1229
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
base: main
Are you sure you want to change the base?
Changes from all commits
7b5b435
2e6f3a3
5134ec8
a3170c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // npx vitest run src/__tests__/types.test.ts | ||
|
|
||
| import { contributesSchema } from "../types.js" | ||
|
|
||
| describe("contributes commands schema", () => { | ||
| // Reached through `.shape` so this stays focused on the icon field, without needing a whole | ||
| // valid `contributes` object around it. | ||
| const commandsSchema = contributesSchema.shape.commands | ||
|
|
||
| const command = (icon: unknown) => [ | ||
| { command: "zoo-code.generateCommitMessage", title: "%command.generateCommitMessage.title%", icon }, | ||
| ] | ||
|
|
||
| it("accepts a codicon reference", () => { | ||
| expect(commandsSchema.safeParse(command("$(edit)")).success).toBe(true) | ||
| }) | ||
|
|
||
| // The Source Control button ships a PNG per theme rather than a codicon. This field used to | ||
| // allow only a string, which rejected the manifest outright when generating the nightly build. | ||
| it("accepts a pair of theme-specific icon paths", () => { | ||
| const icon = { light: "assets/icons/panel_light.png", dark: "assets/icons/panel_dark.png" } | ||
|
|
||
| expect(commandsSchema.safeParse(command(icon)).success).toBe(true) | ||
| }) | ||
|
|
||
| it("rejects an icon pair that is missing a theme", () => { | ||
| expect(commandsSchema.safeParse(command({ light: "assets/icons/panel_light.png" })).success).toBe(false) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,6 +235,13 @@ export const globalSettingsSchema = z.object({ | |
| customSupportPrompts: customSupportPromptsSchema.optional(), | ||
| enhancementApiConfigId: z.string().optional(), | ||
| includeTaskHistoryInEnhance: z.boolean().optional(), | ||
| commitMessageApiConfigId: z.string().optional(), | ||
| /** | ||
| * Seconds to wait for a commit message before giving up. Most providers ignore the abort | ||
| * signal, so without a bound a request that never answers leaves the indicator up until the | ||
| * window is reloaded. | ||
| */ | ||
| commitMessageTimeout: z.number().int().min(10).max(600).optional(), | ||
|
Comment on lines
+238
to
+244
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 5 \
'commitMessageTimeout|DEFAULT_COMMIT_MESSAGE_TIMEOUT|timeout.*(ms|seconds)|AbortSignal|setTimeout' \
src/core/webview/ClineProvider.ts \
src/services/commit-message \
packages/types/src/global-settings.tsRepository: Zoo-Code-Org/Zoo-Code Length of output: 17276 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- global-settings.ts ---'
sed -n '1,115p' packages/types/src/global-settings.ts
sed -n '220,255p' packages/types/src/global-settings.ts
printf '%s\n' '--- commit-message config and runtime ---'
sed -n '1,95p' src/services/commit-message/config.ts
sed -n '130,220p' src/services/commit-message/index.ts
printf '%s\n' '--- commit-message tests ---'
sed -n '1,115p' src/services/commit-message/__tests__/config.spec.ts
rg -n -C 4 'commitMessageTimeout' --glob '*.{ts,tsx}' --glob '!node_modules/**'Repository: Zoo-Code-Org/Zoo-Code Length of output: 15520 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- all setting references ---'
rg -n -C 3 'commitMessageTimeout|DEFAULT_COMMIT_MESSAGE_TIMEOUT_SECONDS' .
printf '%s\n' '--- related global-setting defaults and exports ---'
rg -n -C 3 'DEFAULT_.*TIMEOUT|MIN_.*TIMEOUT|MAX_.*TIMEOUT|globalSettingsSchema|GlobalSettings' packages/types/src src --glob '*.{ts,tsx}'
printf '%s\n' '--- focused source ranges ---'
sed -n '1,130p' packages/types/src/global-settings.ts
sed -n '255,330p' packages/types/src/global-settings.tsRepository: Zoo-Code-Org/Zoo-Code Length of output: 50377 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
root = Path(".")
refs = []
for path in root.rglob("*"):
if not path.is_file() or any(part in {"node_modules", ".git", "dist", "build"} for part in path.parts):
continue
try:
text = path.read_text()
except (UnicodeDecodeError, OSError):
continue
for line_no, line in enumerate(text.splitlines(), 1):
if "commitMessageTimeout" in line or "DEFAULT_COMMIT_MESSAGE_TIMEOUT_SECONDS" in line:
refs.append((str(path), line_no, line.strip()))
print("references:", len(refs))
for item in refs:
print(f"{item[0]}:{item[1]}:{item[2]}")
schema = Path("packages/types/src/global-settings.ts").read_text()
match = re.search(
r"commitMessageTimeout:\s*z\.number\(\)\.int\(\)\.min\((\d+)\)\.max\((\d+)\)\.optional\(\)",
schema,
)
print("schema_bounds:", match.groups() if match else None)
config = Path("src/services/commit-message/config.ts").read_text()
default = re.search(r"DEFAULT_COMMIT_MESSAGE_TIMEOUT_SECONDS\s*=\s*(\d+)", config)
conversion = "(commitMessageTimeout ?? DEFAULT_COMMIT_MESSAGE_TIMEOUT_SECONDS) * 1000" in config
print("service_default_seconds:", default.group(1) if default else None)
print("seconds_to_milliseconds_conversion:", conversion)
for value in [None, 10, 600, 120]:
seconds = (value if value is not None else int(default.group(1)))
print(f"effective_timeout_ms[{value!r}]:", seconds * 1000)
PYRepository: Zoo-Code-Org/Zoo-Code Length of output: 1387 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- ClineProvider state methods ---'
sed -n '2520,2620p' src/core/webview/ClineProvider.ts
sed -n '2770,2860p' src/core/webview/ClineProvider.ts
printf '%s\n' '--- ContextProxy validation and state access ---'
rg -n -C 8 'setValue|getGlobalSettings|getValues|globalSettingsSchema.parse|GLOBAL_SETTINGS_KEYS' src/core/config/ContextProxy.ts
printf '%s\n' '--- setting message and UI references ---'
rg -n -C 5 'commitMessageApiConfigId|commit.message|commitMessage' src webview-ui packages --glob '*.{ts,tsx,json}' | head -n 300Repository: Zoo-Code-Org/Zoo-Code Length of output: 41291 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
context = Path("src/core/config/ContextProxy.ts").read_text()
get_global = re.search(
r"public getGlobalSettings\(\): GlobalSettings \{(?P<body>.*?)\n\t\}",
context,
re.S,
)
if not get_global:
raise SystemExit("getGlobalSettings body not found")
body = get_global.group("body")
print("getGlobalSettings_uses_schema_parse:", "globalSettingsSchema.parse(values)" in body)
print("getGlobalSettings_returns_raw_values_on_parse_error:", "GLOBAL_SETTINGS_KEYS.reduce" in body)
config = Path("src/services/commit-message/config.ts").read_text()
print(
"runtime_clamps_invalid_values:",
"Math.max" in config or "Math.min" in config or "globalSettingsSchema.parse" in config,
)
all_text = "\n".join(
path.read_text(errors="ignore")
for root in ("src", "webview-ui", "packages")
for path in Path(root).rglob("*")
if path.is_file() and path.suffix in {".ts", ".tsx", ".json"}
)
print("runtime_or_ui_named_consumers:", len(re.findall(r"commitMessageTimeout", all_text)))
PYRepository: Zoo-Code-Org/Zoo-Code Length of output: 329 Propagate
🤖 Prompt for AI AgentsSources: Coding guidelines, Learnings |
||
| historyPreviewCollapsed: z.boolean().optional(), | ||
| reasoningBlockCollapsed: z.boolean().optional(), | ||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2461,6 +2461,7 @@ export class ClineProvider | |
| customModePrompts, | ||
| customSupportPrompts, | ||
| enhancementApiConfigId, | ||
| commitMessageApiConfigId, | ||
| autoApprovalEnabled, | ||
| customModes, | ||
| experiments, | ||
|
|
@@ -2619,6 +2620,7 @@ export class ClineProvider | |
| customModePrompts: customModePrompts ?? {}, | ||
| customSupportPrompts: customSupportPrompts ?? {}, | ||
| enhancementApiConfigId, | ||
| commitMessageApiConfigId, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add state-propagation coverage. This cohort adds no focused As per coding guidelines, “Add focused tests for … the value returned by 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| autoApprovalEnabled: autoApprovalEnabled ?? false, | ||
| customModes, | ||
| experiments: experiments ?? experimentDefault, | ||
|
|
@@ -2852,6 +2854,7 @@ export class ClineProvider | |
| customModePrompts: stateValues.customModePrompts ?? {}, | ||
| customSupportPrompts: stateValues.customSupportPrompts ?? {}, | ||
| enhancementApiConfigId: stateValues.enhancementApiConfigId, | ||
| commitMessageApiConfigId: stateValues.commitMessageApiConfigId, | ||
| experiments: stateValues.experiments ?? experimentDefault, | ||
| autoApprovalEnabled: stateValues.autoApprovalEnabled ?? false, | ||
| customModes, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a package test with both
lightanddarkicon paths make sense here? The current string-codicon fixture would not catch this schema being narrowed again.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/build/src/tests/types.test.ts covers a codicon string, a {light, dark} pair, and an incomplete pair that should be rejected. It reaches the commands schema through contributesSchema.shape.commands, so the test stays focused on the icon field without needing a whole valid contributes object