Skip to content

Conversation

@EvilGenius13
Copy link
Contributor

WHY are these changes introduced?

Fixes https://github.com/Shopify/developer-tools-team/issues/918

If you copy and paste in the terminal when running theme dev you can end up with a ton of tabs opening.
Since we are watching for certain keys like t to open localhost, if you were to copy and paste text that had multiple t|p|e|g<-- shortcut keys, you can end up opening a lot of tabs.

WHAT is this pull request doing?

When a key is pressed we create a short lived lock, and any other keys pressed during that time will be ignored. The delay is set to 100ms so we shouldn't see any problems with someone quickly doing something like opening localhost and then the editor for themselves.

I also added some extra keypress tests that we didn't originally have.

How to test your changes?

This is a fun one to test.

  • On a current shopify version, run theme dev and in the console, paste tteeppggtt. This should open 10 tabs.
  • Build this branch and do the same. Only the first key should register (t) and open localhost once.
  • You can also test if it feels snappy enough by manually pressing a couple keys like opening localhost, then the editor, then the preview pane to see how it feels.

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@EvilGenius13 EvilGenius13 requested review from a team as code owners December 11, 2025 18:58
@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.25% (+0.02% 🔼)
13921/17566
🟡 Branches
73.26% (+0.15% 🔼)
6801/9284
🟡 Functions
79.36% (-0.01% 🔻)
3565/4492
🟡 Lines
79.61% (+0.03% 🔼)
13152/16521
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / admin-as-app.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-mutation.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟢
... / get-bulk-operation-by-id.ts
100% 100% 100% 100%
🟢
... / list-bulk-operations.ts
100% 100% 100% 100%
🟢
... / staged-uploads-create.ts
100% 100% 100% 100%
🔴
... / execute.ts
0% 0% 0% 0%
🔴
... / status.ts
0% 0% 0% 0%
🔴
... / pull.ts
0% 100% 0% 0%
🟢
... / execute-operation.ts
92.86% 80% 100% 92.31%
🔴
... / pull.ts
0% 0% 0% 0%
🟢
... / bulk-operation-status.ts
96.15% 90.63% 100% 100%
🟢
... / download-bulk-operation-results.ts
100% 100% 100% 100%
🟢
... / execute-bulk-operation.ts
92.98% 86.11% 100% 92.73%
🟢
... / format-bulk-operation-status.ts
100% 100% 100% 100%
🟢
... / run-mutation.ts
100% 100% 100% 100%
🟢
... / run-query.ts
100% 100% 100% 100%
🟡
... / stage-file.ts
72.73% 62.5% 83.33% 71.88%
🟢
... / watch-bulk-operation.ts
100% 100% 100% 100%
🟢
... / common.ts
96.15% 93.33% 100% 95.45%
🟢
... / execute-command-helpers.ts
100% 100% 100% 100%
🔴
... / promiseWithResolvers.ts
33.33% 50% 50% 33.33%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / execute.ts
0%
0% (-100% 🔻)
0% 0%
🟢
... / extension-instance.ts
84.8% (+0.23% 🔼)
77.6% (-0.91% 🔻)
92.06% (+0.13% 🔼)
85.11% (+0.24% 🔼)
🟡
... / specification.ts
69.09%
75.61% (+2.44% 🔼)
76.47% (-1.31% 🔻)
68.75%
🟢
... / ui_extension.ts
85.38% (-9.44% 🔻)
72.34% (-8.91% 🔻)
84% (-16% 🔻)
88% (-8.46% 🔻)
🟢
... / developer-platform-client.ts
84.62% (-1.5% 🔻)
73.68% (+3.1% 🔼)
81.82% (+1.82% 🔼)
90.63% (-2.71% 🔻)
🟢
... / api.ts
87.07% (-0.43% 🔻)
76.71% (-0.1% 🔻)
100%
86.49% (-0.43% 🔻)
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
92% (-4% 🔻)
100%
98.33% (-1.67% 🔻)
🟢
... / SingleTask.tsx
84.21% (-15.79% 🔻)
50% (-50% 🔻)
80% (-20% 🔻)
84.21% (-15.79% 🔻)
🔴
... / ui.tsx
50.82% (-0.79% 🔻)
42.86% (-5.53% 🔻)
54.55% (+1.42% 🔼)
50% (-0.82% 🔻)
🟢
... / console.ts
81.82% (+15.15% 🔼)
75% (-25% 🔻)
100% (+33.33% 🔼)
81.82% (+15.15% 🔼)
🟢
... / init.ts
88% (-0.89% 🔻)
71.43% (+4.76% 🔼)
86.67% (+4.85% 🔼)
88% (-0.89% 🔻)
🟢
... / storefront-renderer.ts
90.2% (-0.54% 🔻)
78.95%
81.82% (-1.52% 🔻)
90.2% (-0.54% 🔻)
🟡
... / theme-polling.ts
67.12% (-0.93% 🔻)
68.75% 78.57%
66.67% (-0.98% 🔻)

Test suite run success

3493 tests passing in 1407 suites.

Report generated by 🧪jest coverage report action from eda441d

@graygilmore
Copy link
Contributor

/snapit

Copy link
Contributor

@graygilmore graygilmore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎩 went great but I'm a little confused about the unused function


// This prevents the keypress handler from being called multiple times in a short span
keyBlock = true
setTimeout(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you familiar with debouncing? We have a debounce helper function that we could potentially use here instead? Might be overkill for what you're doing but it's there if you want! https://github.com/Shopify/cli/blob/main/packages/cli-kit/src/public/common/function.ts#L39

We could use leading: true to make sure we don't delay the first keypress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I could use the helper since it's already available. Let me check this out!

@EvilGenius13 EvilGenius13 force-pushed the theme-dev-shortcut-debounce branch from d29fe1e to cd9753f Compare December 11, 2025 20:58
@EvilGenius13 EvilGenius13 force-pushed the theme-dev-shortcut-debounce branch from cd9753f to eda441d Compare December 11, 2025 21:17
switch (key.name) {
case 't':
openURLSafely(urls.local, 'localhost')
debouncedOpenURL(urls.local, 'localhost')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might've debounced the click handler instead of the URL opening itself but this works, too!

Copy link
Contributor

@dejmedus dejmedus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a super fun 🎩 Looks great!

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.

3 participants