Skip to content

Add Class entry to New File... quickpick#1732

Merged
gjsjohnmurray merged 7 commits intomasterfrom
copilot/add-class-entry-quickpick
Mar 17, 2026
Merged

Add Class entry to New File... quickpick#1732
gjsjohnmurray merged 7 commits intomasterfrom
copilot/add-class-entry-quickpick

Conversation

Copy link
Contributor

Copilot AI commented Mar 6, 2026

The New File... quickpick only offered interoperability-specific class types, leaving no guided path for creating a plain ObjectScript class. New users struggled with naming conventions, separators, and the required .cls suffix.

Changes

  • src/commands/newFile.ts

    • Added Class = "Class" to NewFileType enum
    • Skips the interoperability namespace check for the new type (alongside existing KPI exception)
    • Adds a 3-step wizard driven entirely by multiStepInput: (1) class name, (2) optional description, (3) optional superclass via a new classPick step type
    • Prompt title reads "Enter a name for the new class" (avoids the redundant "new Class class" phrasing)
    • Added ClassPickStepOptions interface (type: "classPick", title, api) and extended the InputStepOptions union to include it
    • multiStepInput handles the classPick type: uses the expandable class picker when connected to a server, falls back to an InputBox otherwise; Escape skips the optional step (never cancels the wizard), Back navigates to the previous step
  • src/commands/project.ts — exports a pickClass(api, title, canGoBack?) function: an expandable single-select QuickPick for classes using %Library.RoutineMgr_StudioOpenDialog, reusing PickAdditionsItem and sodItemToPickAdditionsItem from the Add Items to Project command; includes System/Generated toggles, auto-expand-on-dot, collapse support, optional Back button, and a settled flag to prevent double-resolution

  • src/extension.ts — registers vscode-objectscript.newFile.class command

  • package.json — adds Class to contributes.commands and file/newFile menu; hides the command from the Command Palette (consistent with all other newFile.* commands)

When connected to a server the superclass step shows an expandable class picker (only .cls files offered, single-select, with Back button support); when there is no server connection it falls back to a plain InputBox with class-name validation. Pressing Escape on the superclass step skips it.

Generated template for My.Package.ClassName with description "A test class" and no superclass:

/// A test class
Class My.Package.ClassName
{

}

Generated template for Foo.Bar with superclass %Library.Persistent:

Class Foo.Bar Extends %Library.Persistent
{

}
Original prompt

This section details on the original issue you should resolve

<issue_title>Support creation of a class from the New File... quickpick</issue_title>
<issue_description>
Type: Feature Request

The file types we contribute to the New File... quickpick (accessed from the New File... option of the File menu) misses one for a simple class.

Image

I have observed new users struggling to work out how to create a new class in their workspace. Even when they do find the New File button on the workspace titlebar in Explorer view they aren't always sure how much of the package path they need to add, or whether to use dot or slash separators. Some omit the .cls suffix and receive an opaque error message from the extension.

I suggest we add a Class entry. As a minimum, prompt for the name like the interop entries do, e.g.

Image

For extra points, prompt for a description and maybe a superclass (with a picker?).

This would go some way towards matching what the old Studio's New Class wizard did.

Extension version: 3.6.1-beta.3
VS Code version: Code 1.110.0 (0870c2a0c7c0564e7631bfed2675573a94ba4455, 2026-03-04T01:20:28.863Z)
OS version: Windows_NT x64 10.0.26200
Modes:

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: gjsjohnmurray <6726799+gjsjohnmurray@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for creating a class from New File quickpick Add Class entry to New File... quickpick Mar 6, 2026
@gjsjohnmurray gjsjohnmurray marked this pull request as ready for review March 6, 2026 09:22
@gjsjohnmurray
Copy link
Contributor

@copilot please hide the new Class command from Command Palette

Co-authored-by: gjsjohnmurray <6726799+gjsjohnmurray@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot please hide the new Class command from Command Palette

Done in 41df5f1. Added vscode-objectscript.newFile.class to contributes.menus.commandPalette with "when": "false", consistent with all other newFile.* commands.

@gjsjohnmurray
Copy link
Contributor

@copilot please add a third step to the user interaction, prompting for an optional superclass. Look at the Add Items to Project... command for inspiration on how to help the user select an existing class as the superclass. However, unlike for that command, in this situation you must only offer classes (these have a .cls extension).

Try to reuse code rather than duplicating it.

When the user does pick a superclass, use it in the document you generate. For example:

Class Foo.Bar Extends %Library.Persistent

Co-authored-by: gjsjohnmurray <6726799+gjsjohnmurray@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot please add a third step to the user interaction, prompting for an optional superclass. Look at the Add Items to Project... command for inspiration on how to help the user ...

Done in e73b96c.

A third step now prompts for an optional superclass. When connected to a server it uses an expandable QuickPick (reusing PickAdditionsItem and sodItemToPickAdditionsItem from project.ts, with the same System/Generated toggles and auto-expand-on-dot behaviour as the Add Items to Project picker, but filtering to *.cls only and single-select). When there is no server connection it falls back to a plain InputBox with class-name validation.

If a superclass is chosen, the generated class includes the Extends clause:

Class Foo.Bar Extends %Library.Persistent
{

}

Pressing Escape on the superclass step skips it and produces a plain Class Foo.Bar { }.

@gjsjohnmurray
Copy link
Contributor

@copilot please integrate the class picking step into the multiStepInput function by adding a new ClassPickStepOptions interface that the InputStepOptions type will accept.

Co-authored-by: gjsjohnmurray <6726799+gjsjohnmurray@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 6, 2026

@copilot please integrate the class picking step into the multiStepInput function by adding a new ClassPickStepOptions interface that the InputStepOptions type will accept.

Done in 60db6b1.

Added ClassPickStepOptions { type: "classPick"; title: string; api: AtelierAPI | undefined } and updated the InputStepOptions union to include it. The multiStepInput function now handles the classPick type directly:

  • When api is set, calls pickClass (updated to accept a canGoBack flag and Back button support)
  • When api is undefined, falls back to an InputBox with class-name validation
  • Escape = skip this optional step (stores "", advances)
  • Back = decrement step like other step types
  • Never cancels the wizard

The NewFileType.Class block now simply pushes { type: "classPick", ... } onto inputSteps and reads results[2] for the superclass, with no separate prompt logic outside multiStepInput.

@gjsjohnmurray
Copy link
Contributor

gjsjohnmurray commented Mar 6, 2026

@isc-bsaviano @isc-rsingh I think Copilot did a pretty good job using Claude Sonnet 4.6, and the PR deserves to be merged.

If you're interested in the process, see it here. Seems like the agent session isn't visible to people other than myself as creator.

@isc-bsaviano
Copy link
Contributor

Look like a fun experiment John! I'll review in detail after KC's change. I can't read that link FYI.

@isc-rsingh I think we should write up a policy related to agent-only PRs into CONTRIBUTING.md. I know it's unlikely but I don't want us to be drowning in PRs thst we didn't ask for. That has happened to other open source projects, although they were much bigger.

@gjsjohnmurray
Copy link
Contributor

@isc-bsaviano looks like the session link isn't shareable. I've updated my comment.

I agree re adding something to CONTRIBUTING.md

@isc-bsaviano
Copy link
Contributor

We actually might not need anything. We already have language on getting agreement on a spec before implementation for features. Once that's settled then there's probably nothing wrong with the user letting AI do the work.

@isc-bsaviano
Copy link
Contributor

Thanks for making the changes John. Just tested and looks good to me. @isc-klu Any feedback before I approve?

@gjsjohnmurray gjsjohnmurray merged commit 969b08d into master Mar 17, 2026
5 checks passed
@gjsjohnmurray gjsjohnmurray deleted the copilot/add-class-entry-quickpick branch March 17, 2026 01:49
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.

Support creation of a class from the New File... quickpick

3 participants