Skip to content

fix(init): preserve additional roles selected at the prompt - #765

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
dvd233:contrib/fix-init-role-selection
Sep 24, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
dvd233:contrib/fix-init-role-selection

Conversation

@dvd233

@dvd233 dvd233 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve every role number entered at the interactive teamai init role prompt.
  • Save the first selected role as primaryRole and later selections as additionalRoles.
  • Document the comma-separated input in the English and Chinese usage guides and setup reference.

Fixes #759

Why

The prompt and its validation message already described comma-separated role numbers, but init destructured only the first parsed index and silently discarded the remaining selections. This made the saved configuration disagree with the user's input and caused role-scoped resources to omit the requested additional namespaces.

The change reuses the existing parseRoleSelection validation/deduplication and the existing LocalConfig.additionalRoles consumers. The non-interactive --role <id> path remains a single-primary-role path.

Validation

Passed:

  • git diff --check
  • npx vitest run src/__tests__/init.test.ts -t 'role persistence' — 2 passed
  • npm run typecheck
  • npm run build

The new regression test verifies that entering 1,3 persists primaryRole: 'hai' and additionalRoles: ['thpc'].

I also ran the repository-wide suites. The full unit run and npm run test:e2e are not green in this Windows sandbox because of unrelated environment-sensitive failures (Windows path separator assertions, spawned-process EINVAL/ENOENT, socket/fixture failures, and a nested temporary-path length failure); the new role-persistence test passes. The real CLI was exercised against an isolated fixture: it loaded the role manifest, displayed the available roles, accepted 1,3, and proceeded past role selection before the environment-limited hook flow timed out. No remote team repository or production project was used.

@jeff-r2026 jeff-r2026 self-assigned this Sep 23, 2026
@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] src/init.ts:117 — Consuming every result from parseRoleSelection exposes its permissive parseInt behavior: inputs such as 1,3foo select role 3, while 1,foo,3 silently ignores the invalid token. Validate every comma-separated token as a complete integer before persisting additional roles.
  • [P1 blocking] The PR description lacks a successful end-to-end/real-CLI verification. It states that npm run test:e2e failed and the manual CLI flow timed out, without confirming the resulting persisted configuration through the real CLI. Repository rules require the relevant real-CLI test plan to complete successfully before merge.

@jeff-r2026
jeff-r2026 merged commit 5576b38 into Tencent:main Sep 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] init role prompt accepts 1,3 but keeps only the first role

2 participants