Skip to content

Introduce shared port state, refactor file manager and update commands/views#1

Open
daleka wants to merge 37 commits into
mainfrom
codex/analyze-code-and-provide-report
Open

Introduce shared port state, refactor file manager and update commands/views#1
daleka wants to merge 37 commits into
mainfrom
codex/analyze-code-and-provide-report

Conversation

@daleka

@daleka daleka commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Replace ad-hoc global port state with a small shared state module to make port selection accessible across modules.
  • Refactor file manager and extension activation to use a dedicated file manager view and modernized commands/labels.
  • Resolve merge conflict residues and unify command titles/icons for the updated UI.

Description

  • Add src/sharedState.ts providing setSelectedPort and getSelectedPort and switch modules to use it instead of global variables.
  • Update src/extension.ts to register the file manager, dependency/save/compile commands, add status bar items, improve device info fetching and change how the selected port is stored (now uses setSelectedPort).
  • Update src/fileManager.ts to read the selected port via the shared state, normalize remote paths with getRemoteFilePath, and show a Select Port tree item when no port is chosen.
  • Modify package.json to rename views/containers/commands and update command titles/icons, and remove lingering merge conflict markers.

Testing

  • Ran npm run compile to build TypeScript and it completed successfully.
  • Ran npm run lint (ESLint) and it passed without errors.
  • Ran npm test (VS Code test harness) and the automated tests completed successfully.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f1e1dd456

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
@@ -25,13 +25,6 @@
},
{
"command": "mpytools.compileAndMount",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use the registered compile command ID in contributes

This contribution now advertises mpytools.compileAndMount, but the extension only registers mpytools.compileAndRun (see registerCompileAndRunCommand in src/compileAndRun.ts). In this state, invoking the contributed “Compile PY → MPY and mount” command from the Command Palette or a keybinding will fail with a missing-command error, breaking the primary compile/upload workflow unless users happen to use the status-bar button.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 562213be76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/extension.ts Outdated
function delay(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
const connectTarget = port === 'auto' ? 'auto' : port;
await execPromise(`mpremote connect ${connectTarget} exec "import main; print('__MPY_READY__')"`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid aborting Compile&Run on main import precheck

The new preflight await execPromise(...) in openTerminalAndRunMain will reject when main.py is missing or raises during import, which now aborts mpytools.compileAndRun before the terminal ... + repl command is sent. In that failure path users lose the interactive recovery flow and the Compile&Run status bar item can remain in its spinning state because the reset logic in registerCompileAndRunCommand is after this awaited call. Handle this precheck failure as non-fatal (or guard with try/finally) so the command can still recover cleanly.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dce4278c56

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
Comment on lines 25 to 27
},
{
"command": "mpytools.compileAndMount",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Drop stale connect command or register it again

package.json still contributes mpytools.connect, but after the conflict-resolution changes in src/extension.ts there is no registerCommand('mpytools.connect', ...) implementation anymore. Invoking that contributed command from the Command Palette now results in a missing-command error, which breaks a visible user entry point for connecting to a device.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

mpytools/package.json

Lines 35 to 37 in 8838ad8

"command": "mpytools.openMicroPythonProject",
"title": "📂Open Project"
},

P2 Badge Register contributed project commands

This commit exposes mpytools.openMicroPythonProject, mpytools.openInExplorer, and mpytools.saveAllDirty in contributes.commands, but there is no matching vscode.commands.registerCommand(...) for any of them in src at this revision. Invoking these entries from the Command Palette will throw a missing-command error, so users see visible actions that cannot run.


mpytools/package.json

Lines 109 to 111 in 8838ad8

"command": "mpytoolsFileExplorer.refreshFolder",
"when": "viewItem == device-folder",
"group": "navigation"

P2 Badge Implement folder refresh command used by context menu

The file explorer context menu binds folder refresh to mpytoolsFileExplorer.refreshFolder, but src/fileManager.ts only registers mpytoolsFileExplorer.refresh and mpytoolsFileExplorer.refreshDevice. As a result, clicking “Refresh folder” on a device folder fails with a missing-command error and the advertised folder-level refresh path is broken.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

mpytools/package.json

Lines 35 to 47 in bc3255a

"command": "mpytools.openMicroPythonProject",
"title": "📂Open Project"
},
{
"command": "mpytools.openInExplorer",
"title": "🗃️Explorer"
},
{
"command": "mpytools.saveAllDirty",
"title": "💾Save All"
},
{
"command": "mpytoolsFileExplorer.refreshFolder",

P2 Badge Register newly contributed command IDs

package.json now contributes mpytools.openMicroPythonProject, mpytools.openInExplorer, mpytools.saveAllDirty, and mpytoolsFileExplorer.refreshFolder, but none of these IDs are registered in the active extension code (src/extension.ts/src/fileManager.ts only register other command names). In this state, Command Palette entries and the folder context-menu action will raise VS Code “command not found” errors when invoked, so visible UI actions are broken for users.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a093fb5ceb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tsconfig.json Outdated
Comment on lines +9 to +11
"types": [
"node",
"vscode"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore mocha types in TypeScript config

Restricting compilerOptions.types to only node and vscode removes the Mocha global typings from the build, but test sources in this repo use global suite/test (for example src/test/extension.test.ts). Because npm run compile runs tsc -p ./, this change can make the default compile step fail with missing-name errors unless mocha is added back to types (or tests are excluded).

Useful? React with 👍 / 👎.

Comment thread src/extension.ts
Comment on lines +645 to +647
await new Promise(resolve => setTimeout(resolve, 1500));
mpyOutputChannel.appendLine('⚙️ Sending Ctrl-C to ensure REPL prompt is ready');
debugTerminal.sendText('\x03', false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid sending Ctrl-C before REPL startup is confirmed

The new flow unconditionally sends \x03 after a fixed 1.5s delay, so on slower devices/ports this can interrupt the just-started mpremote connect ... repl process before the REPL is actually ready. In that case the subsequent import main; main.run() is no longer guaranteed to run in the device REPL, causing intermittent Compile&Run failures. This should wait for readiness (or avoid forced Ctrl-C) instead of using a fixed timer.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytoolsFileExplorer.refreshFolder",

P2 Badge Register refreshFolder command before contributing it

mpytoolsFileExplorer.refreshFolder is contributed and exposed in the folder context menu, but registerFileManager only registers mpytoolsFileExplorer.refresh and mpytoolsFileExplorer.refreshDevice; there is no registerCommand('mpytoolsFileExplorer.refreshFolder', ...) in src/fileManager.ts (repo-wide rg over src). Selecting that menu action will therefore fail at runtime with a missing-command error instead of refreshing the folder.


"command": "mpytools.openMicroPythonProject",

P2 Badge Remove or implement stale project utility commands

mpytools.openMicroPythonProject, mpytools.openInExplorer, and mpytools.saveAllDirty are still advertised in contributes.commands, but there are no matching registerCommand(...) handlers for these IDs anywhere under src (checked with rg). Invoking these Command Palette entries will produce missing-command errors, so users are presented with actions that cannot execute.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytools.openMicroPythonProject",

P2 Badge Remove unregistered commands from extension manifest

This commit leaves several contributed commands without any registerCommand handler (mpytools.openMicroPythonProject, mpytools.openInExplorer, mpytools.saveAllDirty, and mpytoolsFileExplorer.refreshFolder), so they appear in the Command Palette/context menu but fail at runtime with a missing-command error. I checked the registrations in src/extension.ts, src/saveProject.ts, and src/fileManager.ts, and none of these IDs are implemented there.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ed237b3866

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .vscode/launch.json
Comment on lines +19 to 22
"preLaunchTask": "compile"
}
]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore valid JSONC structure in launch config

The edited launch.json has mismatched closing brackets/braces, so VS Code cannot parse this debug configuration. In practice, the “Run Extension” launch target becomes unavailable (or the file is ignored), which breaks the standard F5 extension-host workflow for contributors.

Useful? React with 👍 / 👎.

Comment thread src/compileAndRun.ts Outdated
fs.writeFileSync(tempPyFile, wrapperCode, 'utf-8');

try {
await execPromise(`mpy-cross "${tempPyFile}" -o "${outPath}"`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Compile asset wrappers with device bytecode flags

This new asset path invokes mpy-cross without the compatibility flags used for normal .py compilation (e.g., bytecode/arch/small-int settings), so generated *_asset.mpy files can be incompatible with the connected firmware. On devices whose MicroPython bytecode version differs from the host mpy-cross default, importing these wrapped assets will fail even though regular modules were compiled correctly.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 156f091877

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
Comment on lines +291 to +292
const withoutExt = ext ? relativeFromSrc.slice(0, -ext.length) : relativeFromSrc;
const assetRelative = `${withoutExt}.mpy`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve unique output names for wrapped non-Python assets

getAssetOutputPath drops the original extension before appending .mpy, so files like src/config.py and src/config.json both target mpy/config.mpy. During Compile&Run, whichever file is processed last overwrites the other output, which can either erase the compiled Python module or the wrapped asset and cause imports/runtime behavior to break on-device for projects that share a basename across .py and non-.py files.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ab7f11f10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts Outdated
Comment on lines +195 to +199
} else {
// Копіюємо файли, що не мають розширення .py
if (!fs.existsSync(outPath)) {
copyWithMkDir(filePath, outPath);
copiedNonPyCount++;
logAndScroll(` 🔹 Copied (new): ${shortName}`);
} else {
if (!areFilesIdentical(filePath, outPath)) {
copyWithMkDir(filePath, outPath);
copiedNonPyCount++;
logAndScroll(` 🔹 Replaced (updated): ${shortName}`);
} else {
logAndScroll(` 🔹 Skipped (identical ${extName}): ${shortName}`);
const outAssetPath = getAssetOutputPath(filePath, srcPath, mpyPath);
const shouldWrap = needsAssetRecompile(filePath, outAssetPath);

if (shouldWrap) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep non-Python assets present in compiled deployments

In compile mode, every non-.py source now goes through the asset-wrapper path and no raw file copy path remains, so files like config.json, templates, binaries, and even prebuilt .mpy libraries are no longer deployed under their original on-device names. This breaks projects that access assets via open(...) or rely on third-party .mpy modules, because Compile&Run uploads only wrapper outputs instead of the original files.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 33b31b992d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts Outdated
fs.mkdirSync(path.dirname(outPath), { recursive: true });

const moduleBaseName = path.basename(filePath, path.extname(filePath));
const constantName = moduleBaseName.toUpperCase().replace(/[^A-Z0-9]/g, '_') || 'ASSET';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prefix generated asset constant names for digit-leading files

The generated constantName can start with a digit because it is derived directly from the asset basename; for files like src/404.html, wrapper code emits identifiers such as 404 / 404_B64, which are invalid Python names and cause mpy-cross to fail for that asset. This breaks Compile&Run for projects that include non-Python files whose names begin with numbers, so the identifier needs a guaranteed leading letter/underscore.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd9c0966e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
Comment on lines +303 to +304
const workspaceRoot = path.dirname(srcPath);
return path.join(workspaceRoot, 'temp', wrapperRelativePath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Generate wrappers outside the workspace temp folder

getAssetWrapperPyPath hardcodes generated wrapper output to ${workspaceRoot}/temp/..., and the compile flow writes there unconditionally, so projects that already use a temp/ tree can have real files silently overwritten during Compile&Run (for example temp/config.py). This introduces avoidable data loss/noisy diffs in user workspaces; wrapper files should be written to an extension-owned temp location instead of a fixed workspace path.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytoolsFileExplorer.refreshFolder",

P2 Badge Register the folder refresh command before contributing it

The context menu now contributes mpytoolsFileExplorer.refreshFolder for device-folder items, but there is no matching vscode.commands.registerCommand('mpytoolsFileExplorer.refreshFolder', ...) in the extension (only refresh and refreshDevice are registered in src/fileManager.ts). In this state, clicking Refresh folder on a device directory triggers a command-not-found error instead of reloading that node.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 343e666acc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts Outdated
Comment on lines 330 to 331
if (currentMethod !== 'none' || shouldWrapNonPy) {
copyPath = os.platform() === 'win32' ? `${mpyPath}\\.` : `${mpyPath}/.`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Clear stale mpy outputs before no-compilation upload

When shouldWrapNonPy is enabled, uploads always use mpyPath (currentMethod !== 'none' || shouldWrapNonPy), including the No Compilation path. In that mode the code only updates changed files in mpy/ and never removes existing artifacts from earlier compiled runs, so stale/deleted .mpy modules are re-uploaded and can still be imported on-device. This makes switching from compiled mode to no-compilation mode run outdated code unless mpy/ is cleaned first.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 372ac45b5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
Comment on lines +409 to +410
const withoutExt = ext ? relativeFromSrc.slice(0, -ext.length) : relativeFromSrc;
return path.join(mpyPath, `${withoutExt}.py`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep wrapped asset outputs from clobbering .py modules

In the No Compilation + Wrap non-.py files path, getAssetPyOutputPath drops the source extension before appending .py, so src/config.py and src/config.json both target mpy/config.py. During the same run, the raw .py copy and the wrapped asset race to the same destination, so one file overwrites the other (or the wrapper is skipped if mtimes make it look unchanged), which can silently replace a real module with asset wrapper code and break imports/runtime behavior.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d757b4d9e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
Comment on lines +436 to +438
const sourceStat = fs.statSync(sourceFilePath);
const outStat = fs.statSync(outputPath);
return sourceStat.mtime > outStat.mtime;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Rebuild non-.py outputs when timestamps are equal

The new needsFileCopy gate now relies only on sourceStat.mtime > outStat.mtime, so a changed source file is skipped whenever mtimes are equal (common on coarse 1-second timestamp filesystems) or the source timestamp is preserved during copy/checkout. In those cases Compile & Run uploads stale wrapped/raw asset files from mpy/, even though the source content changed. The previous logic compared file contents for non-.py copies, so this is a regression in deployment correctness.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3664ea9a9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
const activePortForSettings = getLastUsedPort();
const savedPortForSettings = context.workspaceState.get<string>(compileSettingsPortKey);
const requiresSelectionForPort = savedPortForSettings !== activePortForSettings;
let currentMethod = context.workspaceState.get<string>(compileMethodSettingKey) ?? getSelectedMethod();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor manual compilation method changes

currentMethod now prefers context.workspaceState over getSelectedMethod(), but the mpytools.selectCompilationMethod command (in src/extension.ts) only updates the in-memory selection and never updates workspaceState. After the first compile stores mpytools.compileMethod, using Settings → “Select Compilation Method” no longer affects later runs unless a port change forces re-selection, so users can unknowingly keep compiling with the old optimization mode.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytools.openMicroPythonProject",

P2 Badge Remove or register leftover contributed commands

The extension still contributes command IDs that have no registerCommand handler (mpytools.openMicroPythonProject, mpytools.openInExplorer, mpytools.saveAllDirty, and mpytoolsFileExplorer.refreshFolder), so invoking them from the Command Palette or folder context menu now throws a "command not found" error. I verified registrations in src/extension.ts, src/fileManager.ts, src/saveProject.ts, and src/compileAndRun.ts and none of these IDs are implemented.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7be354453

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/compileAndRun.ts
// Для режиму "No Compilation": просто підключаємося без відправки main.run()
debugTerminal.sendText(`mpremote connect ${finalPort} exec "import main" + repl`);
}
await openTerminalAndRunMain(finalPort, debugTerminal);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep No Compilation launch from requiring main.run()

Calling openTerminalAndRunMain unconditionally here now applies the main.run() sequence even when the user selected No Compilation. In this mode, projects that rely on import main side effects (and do not define run) will now fail with AttributeError after upload, whereas the previous No Compilation branch only imported main and opened REPL. Please keep a separate no-compilation launch path (or guard main.run() by mode) so this option continues to work for script-style main.py files.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytools.openMicroPythonProject",

P2 Badge Register newly contributed project commands

package.json now contributes mpytools.openMicroPythonProject (and adjacent mpytools.openInExplorer / mpytools.saveAllDirty) to the Command Palette, but there is no matching vscode.commands.registerCommand(...) for these IDs in src (the activation path only registers commands like mpytools.saveProject, mpytools.installDependencies, mpytools.selectPort, etc.). Invoking these contributed commands will throw a missing-command error for users, so these entries should be wired up or removed.


"command": "mpytoolsFileExplorer.refreshFolder",

P2 Badge Wire up folder refresh context command

The view context menu advertises mpytoolsFileExplorer.refreshFolder for folder items, but src/fileManager.ts registers only mpytoolsFileExplorer.refresh and mpytoolsFileExplorer.refreshDevice. As a result, clicking “Refresh folder” on a device folder triggers a missing-command failure instead of refreshing the subtree.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

"command": "mpytools.openMicroPythonProject",

P2 Badge Register contributed project utility commands

package.json contributes mpytools.openMicroPythonProject, mpytools.openInExplorer, and mpytools.saveAllDirty, but this commit does not register handlers for those IDs anywhere in src (the registered IDs in extension.ts, saveProject.ts, and compileAndRun.ts are different). As a result, these commands appear in the Command Palette but fail with a missing-command error when invoked.


"command": "mpytoolsFileExplorer.refreshFolder",

P2 Badge Register the folder refresh command you contribute

The extension contributes mpytoolsFileExplorer.refreshFolder to both contributes.commands and the folder context menu, but registerFileManager only registers mpytoolsFileExplorer.refresh and mpytoolsFileExplorer.refreshDevice. Right-clicking a folder and choosing refresh therefore triggers a missing-command error instead of reloading that node.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant