Skip to content

perf(completion): keep Tab completion off telemetry and heavy imports - #2064

Open
ryandemelo wants to merge 1 commit into
Fission-AI:mainfrom
ryandemelo:perf/fast-tab-completion
Open

ryandemelo wants to merge 1 commit into
Fission-AI:mainfrom
ryandemelo:perf/fast-tab-completion

Conversation

@ryandemelo

@ryandemelo ryandemelo commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2026 (items 1 and 2)

What this changes

Shell completion scripts run openspec __complete <type> on every Tab press. Each press loaded 344 modules, including zod, yaml, fast-glob and ora, and with telemetry on it waited for the usage request before exiting.

  • __complete skips the telemetry and completion tip hooks. The scripts send stderr to /dev/null, so this also stops a first Tab press from marking the telemetry notice as seen where nobody can read it.
  • ora loads only in completion install and uninstall, the two places that show a spinner.
  • getSchemaNames loads listSchemas from resolver.js when it runs, instead of importing it through the artifact-graph barrel, which also pulls in fast-glob.

Every other command, including the completion commands a person runs, is tracked as before. Completion output is unchanged.

How you verified it

macOS, Homebrew Node 25.9, sample project with two changes and one spec. Medians of 30 runs after 5 warmups, telemetry off, so the times leave out the request wait this also removes.

openspec __complete Modules before Modules after Median before Median after
changes 344 48 121.6 ms 59.6 ms
specs 344 48 122.3 ms 60.0 ms
schemas 344 219 123.2 ms 85.0 ms

Output was identical before and after for all three.

Tests:

  • startup-modules.test.ts: __complete changes and __complete specs load only commander and never the telemetry module, and __complete schemas loads neither fast-glob nor ora. All three fail on main.
  • cli-is-json-run.test.ts: isTabCompletionRun matches the hidden resolver alone, so completion install and friends stay tracked.

pnpm build && pnpm test && pnpm exec tsc --noEmit && pnpm lint all pass (6412 tests).

Notes

  • __complete schemas still loads yaml and zod, because resolver.js imports the schema parser at the top. That fits with item 6.
  • The rest of item 1, not waiting on telemetry for the other commands, changes how events get delivered, so it will be its own PR.

  • Ran pnpm changeset if this affects users, and committed the file

Summary by CodeRabbit

  • Performance
    • Shell tab completion for changes and specs now loads fewer modules, completing faster while keeping output unchanged.
    • Tab completion no longer records usage.

Shell completion scripts run `openspec __complete <type>` on every Tab
press. Each press loaded 344 modules (zod, yaml, fast-glob, ora) and, with
telemetry on, waited for the usage request before exiting.

- Skip the telemetry and completion-tip hooks for `__complete`. The
  scripts send stderr to /dev/null, so the first-run notice would also be
  marked seen there without anyone reading it.
- Load `ora` only in install and uninstall, which use the spinner.
- Load `listSchemas` from the resolver inside `getSchemaNames` instead of
  through the artifact-graph barrel, which also pulls in fast-glob.

Completing changes or specs now loads 48 modules (commander only), and
schemas loads 219. Part of Fission-AI#2026, items 1 and 2.
@ryandemelo
ryandemelo requested a review from a team as a code owner October 9, 2026 12:35
@ryandemelo
ryandemelo requested review from clay-good and removed request for a team October 9, 2026 12:35
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Fission-AI/OpenSpec/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 66b8034a-6114-479c-ac90-6cd457a03566

📥 Commits

Reviewing files that changed from the base of the PR and between 9111a76 and f816cde.


📒 Files selected for processing (6)
  • .changeset/faster-tab-completion.md
  • src/cli/index.ts
  • src/commands/completion.ts
  • src/core/completions/completion-provider.ts
  • test/cli-e2e/startup-modules.test.ts
  • test/core/cli-is-json-run.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.



📝 Walkthrough

Walkthrough

Shell completion now bypasses CLI telemetry and completion-tip hooks. It also defers loading spinner and schema modules until their related operations run. Tests check the completion command paths and loaded modules.

Changes

Shell Completion Module Loading

Layer / File(s) Summary
Skip hooks for completion runs
src/cli/index.ts, test/core/cli-is-json-run.test.ts
The CLI detects the hidden __complete command and skips telemetry tracking, completion-tip loading, and telemetry shutdown for that command. Tests check the predicate against completion and unrelated command paths.
Defer completion-only dependencies
src/commands/completion.ts, src/core/completions/completion-provider.ts, test/cli-e2e/startup-modules.test.ts, .changeset/faster-tab-completion.md
Shell installation and removal load ora when starting their spinners. Schema lookup dynamically loads listSchemas when fetching uncached schema names. Startup tests check module loading for changes, specs, and schemas completion. The changeset describes reduced module loading and unchanged completion output.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: tabishb


Merge Risk: ⚪ Minimal · up to f816c

The change limits extra work during hidden shell completion while preserving the normal paths for user-run completion commands. The supplied context identifies no specific issue requiring a merge hold.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: improving tab-completion performance by avoiding telemetry and heavy imports.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 5 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant