Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>P4 WorkbenchNew to Visual Studio Code? Get it now.
P4 Workbench

P4 Workbench

Sehej Jain

|
7 installs
| (0) | Free
Trace a line, compare revisions, and review Perforce workspaces in VS Code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

P4 Workbench

P4 Workbench brings Perforce file history, code review, and workspace operations into VS Code. Select a line to trace its originating changelist, inspect a teammate’s shelf before unshelving it, or compare whole folders in a single editor.

Install and connect

  1. Download the VSIX from GitHub Releases. Run Extensions: Install from VSIX… in VS Code and select the file.
  2. Use VS Code 1.146 or later. Install the P4 command-line client on the machine running the extension host. In a terminal inside your workspace, check that p4 info reports the intended user, client and client root. The connection status item supports password-based ticket renewal. Use p4 login in the workspace terminal for an interactive authentication provider.
  3. Open and trust that folder in VS Code. The extension discovers its Perforce client and populates Source Control on first launch. Use Connect or Switch Workspace to choose a different connection. If VS Code cannot find the executable, set P4 Workbench › Executable to its full path in User Settings.

The extension uses the P4 configuration and tickets available in the command’s working directory. File commands use the selected file’s directory. The sidebar uses the connected client. The status bar shows its user, client, port and ticket state. Select it to sign in, refresh or switch workspaces. In a multi-root workspace, Connect or Switch Workspace changes the sidebar connection. Commands run in trusted workspaces.

Upgrading from a previous VSIX

Version 0.5.1 uses the extension ID sehejjain.p4-workbench. If you installed version 0.5.0 or a preview under sehejjain.depot-studio, apply pending changelist drafts or copy their text somewhere safe before switching. Disable the previous extension, install P4 Workbench, and reconnect your workspace. VS Code keeps the two extensions’ drafts and workspace preferences separately. In your settings and custom keybindings, change the prefix depotStudio. to p4Workbench..

The earlier P4 Workbench 0.1.0 package used the same extension ID as 0.5.1. Installing 0.5.1 replaces that implementation. Review any custom perforce.* settings or keybindings when switching.

Open a client from the Workspace Hub

Run P4 Workbench: Open Workspace Hub from the Command Palette, or expand Perforce Workspace Hub in Source Control after connecting. The hub runs p4 clients -u <user> for your current Perforce user. You can also launch it from an empty window when your P4 connection is configured from your home directory.

Expand a client to search its accessible root and alternate roots for saved .code-workspace files. Select a file marked Open Workspace to load its folders and settings in a new window. If several files match, each has its own row. If none are found, select the root marked Open Folder. Use the refresh icon after creating a workspace file or changing a client.

Only the expanded client is searched. Discovery includes nested folders and skips symbolic-link entries, Git metadata, .p4root and node_modules. For a client rooted at the top of a drive, the hub checks the top level. Clients restricted to another host show their host name.

Trace a change

  • Choose Annotate Line or Annotate File in the editor toolbar or by right-clicking a file’s tab. Line mode follows the caret and shows its changelist beside the line. File mode marks the start of each block and the selected line. Hover an attributed line for the author, origin depot revision and changelist. Right-click its line number and choose Reveal Line Changelist to select and expand the exact change in Perforce Changelists. Local edits show Local until submitted. Use Hide Annotations to clear the current tab.
  • Perforce History (history icon in the editor) follows the active file in Source Control. Select a revision to compare it with its predecessor, or use Compare with Working Copy on any revision to compare it with the current editor buffer, including unsaved edits. Use Open Changelist Details on a revision to read the full description and see the other files submitted with it. The history list remains available while reading a spec or a search tab. Open Perforce File Timeline also shows the file in VS Code’s Explorer Timeline.
  • Compare Two Revisions, Compare Working File with Synced Revision, and Compare Working File with Head open the native diff editor. Show File Integration History opens the submitted integration records for a workspace or depot file. Inspect the contributing revisions, compare the two files, or open the associated changelist.
  • Compare Folders accepts any pairing of local and depot directories. It matches relative paths and opens added, edited and deleted text files in the native multi-file diff editor. Each side supports up to 2,000 files. Binary files and files over 8 MiB are omitted from text comparison and reported. Local traversal skips symbolic links, Git metadata and Perforce server metadata.

Open Time-Lapse

  1. Open a Perforce-tracked text file with at least one submitted revision.
  2. Press Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows or Linux. Run P4 Workbench: Open Perforce Time-Lapse. You can also right-click the file in Explorer and choose P4 Workbench → Open Perforce Time-Lapse.
  3. In Source Control → Perforce Time-Lapse, drag the revision slider or use its arrows. The annotated editor follows the selected revision and tracks an unchanged line across insertions and deletions. Select the changelist subject to review the change.

Review and submit

Open Source Control and select the Perforce repository. Each pending changelist has a group, including empty numbered changes. Working files show edits (M), adds (A), deletes (D), and moves (R). Click an opened file to select it. Double-click, press Enter, or use its compare icon to open the native diff. Hold Cmd on macOS or Ctrl on Windows and Linux to select several files. Use the row’s Revert File… button to review and revert an opened file. The group menu’s Revert Opened Files in Changelist… lets you choose several files together. Revert checks for unsaved buffers, keeps rename pairs together and leaves shelved copies intact. The group menu includes Open Changelist Diff, Submit Changelist, and shelving actions for numbered changes. Use the repository menu to create a changelist or preview offline work.

A Shelf label identifies a numbered changelist with shelved files even when it is collapsed. Its group menu offers Unshelve Entire Changelist… and Unshelve Selected Files…. Starting the latter from a shelf file preselects that path. Shelved files have an S badge. If a file is both open and shelved, each version has its own row. Select the shelf row to compare it with its depot base, or choose Compare Shelf with Working File from its context menu. The repository badge counts opened files.

Select one or more opened files in Source Control and choose Move Selected Files to Changelist… to move them to the default changelist or one of your numbered pending changelists. Review the selected paths before applying. A rename moves as a pair, even if you selected only one side. Existing shelves and unsaved editor text stay in place.

Choose Replace Shelved Files… on a changelist with a shelf to review what will enter, leave, or stay on the shelf. A file reopened in another changelist leaves the old shelf even if it is still on disk. Select a text file for a diff, then return to the review to confirm the replacement. Refresh the review if the saved files or shelf changed while it was open.

When the default changelist contains files, type a description in the Perforce Source Control input and press Ctrl+Enter (Cmd+Enter on macOS) to submit the default changelist. Confirm the file list before submission. Numbered changelists use their own descriptions.

Use Rename Changelist… to change only its description’s first line. The pencil opens its complete Perforce specification. The Changelist Order setting sorts numbered changes in ascending or descending order. New Changelist opens an empty form with the description placeholder selected. The named tab supports multiline descriptions, Files, Jobs and custom fields. Saving keeps the draft in VS Code’s local workspace storage. Apply Changes updates the server. A new form opens under the number Perforce assigns. Use Reload Changelist from Server to resolve a stale draft.

Perforce Changelists groups submitted changes and shelves. Expand a changelist to see its files or compare a shelved file with the working copy. Find Changelists opens a searchable tab for submitted changes, pending changes, shelves and changelist numbers. Expand a result for its full description or open its diff and return to the same results. File selections for sync, reconcile and resolve also stay open with their filters and checkboxes when you switch tabs.

To take part of a colleague’s shelf, expand its result in Find Changelists or right-click it under Perforce Changelists → Shelved and choose Unshelve Selected Files…. Choose your destination changelist, check the paths you need, and review the Perforce preview. Starting from a file in the shelf preselects it. A rename includes both paths. Use Unshelve Entire Changelist… when you also want the shelf’s stream specification.

Choose Open Changelist Details from a changelist’s context menu for the full description, linked jobs, filterable file table or review URL. Set Code Review URL to copy links to your team’s P4 Code Review server.

Work with branch mappings

In Source Control → Perforce Workspace → Branch mappings, use New Branch Mapping to start a specification, or right-click an existing mapping and choose Duplicate Branch Mapping. Review the depot paths in the native text editor, then run Apply Edited Specification to save the mapping to Perforce.

Expand a mapping and choose Forward to follow the view from left to right, or Reverse to go from right to left. Each direction has two views.

  • Outstanding changelists shows submitted source changes with revisions still to integrate. Expand a change to inspect its files, or use Open Changelist Diff to review the whole submission. A changelist can include files outside this branch mapping.
  • Preview integration asks Perforce which target files the connected workspace would open. Select a file to read the incoming source revision. Selecting a deletion shows the content that would be removed. Use Compare Target with Incoming Revision to compare the submitted target with that source. A new target has an empty left side.

To work on a previewed file, right-click it and choose Open for Integration in Changelist. Select a numbered pending changelist and confirm the file. The action opens the target at the reviewed source revision. Use the resolve preview for any pending merges, then review and submit the changelist when ready. If the client view excludes a target, the preview shows Perforce’s diagnostic. Branch integration · Outstanding changelists

Share a Perforce selection with an agent

Select lines in a tracked working file or a submitted revision, then run Pin Perforce Review Context for Chat. For example, while reviewing a working file with unsaved edits, pin the selection and ask, “Which lines came from submitted changelists, and which lines are local?” The pin records the displayed revision and the originating changelist for each range, up to 100 selected lines. Larger selections report how many lines were included. In Branch mappings → Preview integration, right-click a file to pin its mapping, direction, action, source revision and target.

Select P4 review context in the status bar to inspect the exact JSON. In a compatible VS Code chat, reference #p4ReviewContext. For a terminal agent, run Copy Pinned Review Context and paste it into the conversation. The tool reads only the pin. The extension keeps it in memory and gives the agent depot paths and revision metadata without file contents or connection credentials. When a chat uses the tool, its provider can receive that metadata.

Changing focus keeps the pin. Pinning again replaces it. Clear Pinned Review Context, reconnecting, or closing the window clears it.

Manage a workspace

  • The status bar shows the active file’s synced revision and the depot head. Select it to preview incoming revisions for that file. The cloud-download button in Source Control previews the connected client, with counts for adds, updates, and removals. Select the files to sync and confirm. Each preview lists up to 500 files and applies the displayed revisions or removals.
  • Browse the active client’s owner, root, stream and view mappings. Expand Mapped files to see synced, out-of-date and unsynced files. Depots browses the server independently of the client view.
  • Client workspaces and Branch mappings default to the connected Perforce user. Use the filter on either heading and choose All owners to browse shared catalogs. The choice is saved for this VS Code workspace. Streams, jobs and labels remain independently browsable. Open a specification in the text editor to use VS Code’s find and replace, then run Apply Edited Specification. A concurrent form edit requires reopening the form. Link jobs from the Jobs tree.
  • Use Open Stream Map for a searchable parent–child diagram. Select a stream to inspect its specification, switch the active client, or preview a merge into the current stream.
  • Check out, add, rename opened files, mark for delete, lock, unlock and revert. Inspect who has a file open and whether it is locked. Sync a selected revision or preview workspace sync, reconcile and resolve operations. The preview lets you select affected files.
  • Open in P4V uses the optional p4vc executable for graphical conflict resolution, image time-lapse, file revision graphs and creating or updating a code review. Open Perforce Workspace Terminal opens a terminal in the selected connection directory for additional P4 commands.

P4 Workbench has no telemetry or hosted service. Revision text and changelist metadata are read through the configured P4 client. Publishing a changelist or shelf sends the selected work to your Perforce server.

Offline work and settings

Reconcile Entire Perforce Workspace… in the Source Control repository menu scans the connected client’s mappings, including sibling directories when the connection starts in a subfolder. Preview Reconcile Offline Work… uses the connected directory or selected path. Review the scope, checked files and actions before applying.

File automation is opt-in. In Open P4 Workbench Settings, enable checkout on save, marking new files for add or marking removed files for delete independently. Creation and deletion follow VS Code file operations. Use reconcile to collect external filesystem changes. Inspect Effective P4 Workbench Settings… shows each setting’s value and whether it came from the selected folder, workspace, user or default settings. Executable paths belong in user or remote-machine settings.

Development

Use Node.js 24 or later.

npm ci
npm test
npm run package

Press F5 to launch an Extension Development Host. To run the integration suite, put p4 and p4d on PATH, or set P4_BIN and P4D_BIN to their executable paths. Run npm run test:integration. The suite builds a disposable server and client, seeds submitted and shelved revisions, and exercises the extension in an isolated VS Code profile. Set VSCODE_BIN to use an existing VS Code executable. Set P4_WORKBENCH_VSIX to test an installed package.

Release automation

Push a stable tag of the form vX.Y.Z at the commit whose package.json version is X.Y.Z. The Release extension workflow tests the VSIX and attaches it to the GitHub release. Two independent jobs publish that same package as sehejjain.p4-workbench to Visual Studio Marketplace and Open VSX.

To check an existing tag, open Actions → Release extension → Run workflow, select main, enter the tag, and leave publish unchecked. To publish an existing release after setting up a registry, repeat with publish checked. The workflow reuses the VSIX already attached to that GitHub release. If one registry fails, fix its configuration and choose Re-run failed jobs on the run. Release workflow

One-time publisher setup

Both registries exchange the workflow’s GitHub identity for short-lived credentials. Use repository owner sehejjain, repository p4-workbench, and workflow filename release.yml in both trust policies. Leave the GitHub environment field empty. This setup requires no stored personal access tokens.

  1. Visual Studio Marketplace. Sign in to publisher management, select the existing sehejjain publisher, and create a Trusted Publishing policy with the values above. Publisher management · Microsoft’s GitHub Actions setup
  2. Open VSX first upload. Sign in with the publishing account, link the corresponding Eclipse account, and review and accept the Open VSX Publisher Agreement. Download p4-workbench-0.5.1.vsix from the v0.5.1 GitHub release. Upload that file on the Open VSX Publish page. The page creates the sehejjain namespace during upload if it is missing. v0.5.1 release · Open VSX Publish · Publisher Agreement instructions
  3. Open VSX automation. Trusted Publishing requires a published version and verified namespace ownership. If the account is listed as a contributor, claim the sehejjain namespace and wait for the owner role. Then open Settings → Trusted Publishers, choose sehejjain.p4-workbench, and register the GitHub Actions workflow. Claim namespace ownership · Trusted Publishers · Open VSX prerequisites

Credits

The Workspace Hub uses a native tree so its rows follow the workbench theme and keyboard navigation. Each client shows its name and root, following VS Code’s Recent workspaces. Changelist search and specification drafts stay in editor tabs so you can inspect a diff and return to your place, as in VS Code’s Search Editor.

Matt Crouch’s Perforce for VS Code continued Stef Levesque’s original extension. Its changelist specification editor inspired P4 Workbench’s named form tabs, description selection and explicit Apply action. P4 Workbench is an independent implementation. The P4V release notes and P4 command reference inform the workflows.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft