Skip to content

Conversation

@Gianthard-cyh
Copy link

@Gianthard-cyh Gianthard-cyh commented Jan 31, 2026

closes #81.

API Overview

There are two ways to register commands depending on their lifecycle:

  1. registerGlobalCommand: Registers a command that persists globally. Use this for app-wide actions like "Search Packages", "Toggle Theme", or navigation. Usually registered in plugins/command.ts.

  2. registerScopedCommand: Registers a command that only exists while a component is mounted. Use this for context-aware actions like "Copy Install Command" (only relevant when viewing a package). It automatically unregisters when the component unmounts. You can safely use component variables (closures) inside the handler.

Interactive UI (ctx)

The handler receives a ctx object to interact with the Command Palette UI. Both methods return a Promise that resolves when the user finishes.

  • ctx.input({ prompt }): Opens a text input.
  • ctx.select({ prompt, items }): Opens a list for selection.

Example Usage

Here is a quick snippet showing how to use them:

// 1. Global Command (e.g. in a plugin)
registerGlobalCommand({
  id: 'app:hello',
  name: 'Say Hello',
  description: 'Global hello command',
  handler: async (ctx) => {
    // Open an input box
    const name = await ctx.input({ prompt: 'What is your name?' })
    if (name) {
      console.log(`Hello, ${name}!`)
    }
  }
})

// 2. Scoped Command (inside a Vue component)
const version = ref('1.0.0')

registerScopedCommand({
  id: 'pkg:switch-version',
  name: 'Switch Version',
  description: 'Switch package version',
  handler: async (ctx) => {
    // Open a selection list
    // You can access 'version.value' here because it's scoped!
    const selected = await ctx.select({
      prompt: `Current: ${version.value}. Choose new version:`,
      items: [
        { id: 'v1', name: 'v1.0.0' },
        { id: 'v2', name: 'v2.0.0' }
      ]
    })
    
    if (selected) {
      version.value = selected.name
    }
  }
})

@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 1, 2026 0:38am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 1, 2026 0:38am
npmx-lunaria Ignored Ignored Feb 1, 2026 0:38am

Request Review

Co-authored-by: Robin <robin.kehl@singular-it.de>
@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/en-US.json Source changed, localizations will be marked as outdated.
lunaria/files/zh-CN.json Localization changed, will be marked as complete. 🔄️
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@Gianthard-cyh Gianthard-cyh marked this pull request as ready for review February 1, 2026 08:14
Copilot AI review requested due to automatic review settings February 1, 2026 08:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements a Cmd/Ctrl+K “command bar” (quick actions) feature and wires it into the app’s command registration and localization system.

Changes:

  • Added a new CommandBar modal component with filtering + keyboard navigation.
  • Introduced a global command registry composable and initial command registrations (search + install/run/create copy actions).
  • Added global keybinding (Cmd/Ctrl+K) and new i18n strings for command labels/descriptions.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
lunaria/files/zh-CN.json Adds Chinese translations for command bar placeholder and copy actions.
lunaria/files/en-US.json Adds English translations for command bar placeholder and copy actions.
i18n/locales/zh-CN.json Mirrors Chinese command bar/copy-action strings into app locale files.
i18n/locales/en.json Mirrors English command bar/copy-action strings into app locale files.
app/plugins/commands.ts Registers a global “search packages” command for the command bar.
app/composables/useCommandRegistry.ts Adds the command registry API and scoped/global registration helpers.
app/components/InstallCommandTerminal.vue Registers scoped commands for copying install/run/create commands.
app/components/CommandBar.vue New command bar UI (modal) + filtering, selection, triggering, and input/select flows.
app/app.vue Adds global Cmd/Ctrl+K handler and mounts CommandBar.

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.

cmd+K quick actions command bar

4 participants