Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Fixed

- **The socket "Connection timeout" setting is now used.** It had a field, validation and persistence, but the main process always waited a fixed 2 s; `socket:connect` now carries the configured value.

## [5.19.0] - 2026-09-06

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ninjaterm/
├── firmware-test-apps/ # Contains firmware test applications (Arduino sketches and a Zephyr RTT test app) used for exercising NinjaTerm against real hardware.
├── docs/ # Contains Docusaurus website which contains the homepage, installation guide and manual. Self-contained node project.
├── src/ # Contains the Electron application code.
├── tests/ # Contains the end-to-end tests using Playwright.
├── e2e-tests/ # Contains the end-to-end tests using Playwright.
├── web/ # Contains the web-based version of NinjaTerm. Self-contained node project.
```

Expand Down Expand Up @@ -91,7 +91,7 @@ npx vitest run

### E2E Tests

End-to-end (E2E) (a.k.a. integration tests) are performed using [Playwright](https://playwright.dev/). The Playwright tests are located in the `tests/` directory, and the Playwright config is at `playwright.config.ts`.
End-to-end (E2E) (a.k.a. integration tests) are performed using [Playwright](https://playwright.dev/). The Playwright tests are located in the `e2e-tests/` directory, and the Playwright config is at `playwright.config.ts`.

To run just the E2E tests from command line:

Expand Down
21 changes: 11 additions & 10 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Follow-on work identified while doing it:
commented out. Worth confirming they can go.

<details>
<summary>Original analysis (kept for context)</summary>
<summary>Original analysis (kept for context; its checkboxes are historical, see the status above)</summary>

## 1. Terminal data model — the throughput ceiling [perf]

Expand Down Expand Up @@ -184,14 +184,15 @@ the observability and the undo/subtree-replacement case.

Found on the way:

- [ ] **`socketConnTimeoutMs` is a dead setting.** It has a UI field, validation
and persistence, and nothing reads it — the socket connect never passes a
timeout. Either wire it into `socket:connect` or remove it (needs a
migration + UI change, so not done here).
- [ ] **`RxSettingsView` reaches `displaySettings` via
`rxSettings.profileManager.app.settings.displaySettings`** (5 sites) to get
tooltip config. It has `app` in scope; use it. `profileManager` was kept
public on the settings classes only so this didn't break.
- [x] **`socketConnTimeoutMs` was a dead setting.** (done 2026-09-07) It had a
UI field, validation and persistence, and nothing read it; `socket:connect`
now takes `connTimeoutMs` and the main process uses it instead of a fixed
2 s.
- [x] **`RxSettingsView` reached `displaySettings` via
`rxSettings.profileManager.app.settings.displaySettings`** (done 2026-09-07)
— it and `TxSettingsView` now take `displaySettings` as a prop, and the
`profileManager` getters that existed only for this are gone from the
settings classes.
- [x] Seven direct writes to `rxSettings.ansiEscapeCodeParsingEnabled` in
`FakePortsController` bypassed the setter and never persisted. Caught by
the getter-based façade at compile time; fixed.
Expand All @@ -204,7 +205,7 @@ Found on the way:
equivalent is the natural follow-up.

<details>
<summary>Original analysis (kept for context)</summary>
<summary>Original analysis (kept for context; its checkboxes are historical, see the status above)</summary>

## 3. Six settings classes hand-rolling identical load/save plumbing [arch]

Expand Down
15 changes: 10 additions & 5 deletions src/main/socketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const RX_DATA_BATCH_TIMEOUT_MS = 50;
/**
* How long to wait for a socket to connect before timing out.
*/
const SOCKET_CONNECT_TIMEOUT_MS = 2 * 1000;
/**
* Connect timeout used when the renderer does not send one. The renderer
* always does (it is the "Connection timeout" setting); this is a fallback.
*/
const DEFAULT_SOCKET_CONNECT_TIMEOUT_MS = 2 * 1000;

/**
* Stores a mapping of socket connection identifier to the socket object for all currently open socket connections.
Expand Down Expand Up @@ -39,9 +43,10 @@ function sendBatchedData(connectionId: string, mainWindow: BrowserWindow | null)
* @param mainWindow The main window of the application.
*/
export function initializeSocketHandlers(mainWindow: BrowserWindow) {
ipcMain.handle('socket:connect', async (event, options: { host: string; port: number }) => {
ipcMain.handle('socket:connect', async (event, options: { host: string; port: number; connTimeoutMs?: number }) => {
console.log('socket:connect called. options: ', options);
const connectionId = `${options.host}:${options.port}`;
const connTimeoutMs = options.connTimeoutMs ?? DEFAULT_SOCKET_CONNECT_TIMEOUT_MS;
let socket: net.Socket | undefined;

try {
Expand All @@ -50,7 +55,7 @@ export function initializeSocketHandlers(mainWindow: BrowserWindow) {
}

socket = new net.Socket();
socket.setTimeout(SOCKET_CONNECT_TIMEOUT_MS);
socket.setTimeout(connTimeoutMs);

// One problem with sockets is that if you just pull out the ethernet cable after the connection is established,
// nothing will detect it is broken.
Expand Down Expand Up @@ -84,9 +89,9 @@ export function initializeSocketHandlers(mainWindow: BrowserWindow) {
if (!socketRef.destroyed) {
socketRef.destroy();
}
reject(new Error(`Timeout while connecting to socket ${connectionId}. Waited for ${SOCKET_CONNECT_TIMEOUT_MS / 1000} s.`));
reject(new Error(`Timeout while connecting to socket ${connectionId}. Waited for ${connTimeoutMs / 1000} s.`));
}
}, SOCKET_CONNECT_TIMEOUT_MS);
}, connTimeoutMs);

socketRef.on('connect', () => {
if (!settled) {
Expand Down
4 changes: 2 additions & 2 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
* cycles that re-register without that hammer cause callbacks to stack — the
* same byte is then handled twice (or N times) per delivery.
*/
function subscribe<T extends any[]>(

Check warning on line 12 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (windows-2022)

Unexpected any. Specify a different type

Check warning on line 12 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (macos-15)

Unexpected any. Specify a different type

Check warning on line 12 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (ubuntu-latest)

Unexpected any. Specify a different type
channel: string,
callback: (...args: T) => void
): () => void {
const wrapper = (_event: unknown, ...args: T) => callback(...args);
ipcRenderer.on(channel, wrapper as any);

Check warning on line 17 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (windows-2022)

Unexpected any. Specify a different type

Check warning on line 17 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (macos-15)

Unexpected any. Specify a different type

Check warning on line 17 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (ubuntu-latest)

Unexpected any. Specify a different type
return () => {
ipcRenderer.off(channel, wrapper as any);

Check warning on line 19 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (windows-2022)

Unexpected any. Specify a different type

Check warning on line 19 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (macos-15)

Unexpected any. Specify a different type

Check warning on line 19 in src/preload/index.ts

View workflow job for this annotation

GitHub Actions / test-electron (ubuntu-latest)

Unexpected any. Specify a different type
};
}

Expand Down Expand Up @@ -147,7 +147,7 @@

// Socket operations
socket: {
connect: (options: { host: string; port: number }) => ipcRenderer.invoke('socket:connect', options),
connect: (options: { host: string; port: number; connTimeoutMs?: number }) => ipcRenderer.invoke('socket:connect', options),
disconnect: (connectionId: string) => ipcRenderer.invoke('socket:disconnect', connectionId),
writeData: (connectionId: string, data: Uint8Array) => ipcRenderer.invoke('socket:write-data', connectionId, data),

Expand Down Expand Up @@ -278,7 +278,7 @@
isOpen(): Promise<{ success: boolean; isOpen?: boolean; error?: string }>;
};
socket: {
connect(options: { host: string; port: number }): Promise<{ success: boolean; connectionId?: string; error?: string }>;
connect(options: { host: string; port: number; connTimeoutMs?: number }): Promise<{ success: boolean; connectionId?: string; error?: string }>;
disconnect(connectionId: string): Promise<{ success: boolean; error?: string }>;
writeData(connectionId: string, data: Uint8Array): Promise<{ success: boolean; error?: string }>;
onDataReceived(callback: (connectionId: string, data: Buffer) => void): Disposer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ describe('ConnController connection lifecycle', () => {
expect(window.electronAPI.socket.connect).toHaveBeenCalledWith({
host: '192.168.1.5',
port: 1234,
connTimeoutMs: 2000,
});
expect(conn.connState).toBe(ConnState.OPENED);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class SocketTransport implements Transport {
const target = this.connectedTo ?? {
host: this.session.settings.portConfiguration.socketHost,
port: this.session.settings.portConfiguration.socketPort,
connTimeoutMs: this.session.settings.portConfiguration.socketConnTimeoutMs.appliedValue,
};

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeAutoObservable } from 'mobx';
import { z } from 'zod';

import type { AppDataManager } from 'src/model/AppDataManager/AppDataManager';
import type { Session } from 'src/model/Session/Session';
import type { DisplaySettingsData } from 'src/model/AppDataManager/DataClasses/DisplaySettingsData';
import { SettingsBranch } from '../SettingsBranch';
Expand Down Expand Up @@ -76,11 +75,6 @@ export const TERMINAL_FONT_FALLBACK_STACK = `${NINJATERM_FONT_FAMILY}, ${SYSTEM_
export default class DisplaySettings {
session: Session;

/** App-wide data (presets, MCP flags). Reached through the session. */
get profileManager(): AppDataManager {
return this.session.app.profileManager;
}

/** See `SettingsBranch` for how this class relates to `DisplaySettingsData`. */
private readonly branch = new SettingsBranch<DisplaySettingsData>(
'settings.displaySettings',
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/src/model/Settings/PortSettings/PortSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeAutoObservable, runInAction } from 'mobx';
import { z } from 'zod';

import type { AppDataManager } from 'src/model/AppDataManager/AppDataManager';
import type { Session } from 'src/model/Session/Session';
import { ConnController } from '@/model/ConnController/ConnController';
import type { PortSettingsData } from 'src/model/AppDataManager/DataClasses/PortSettingsData';
Expand Down Expand Up @@ -68,11 +67,6 @@ export class PortSettings {

session: Session;

/** App-wide data (presets, MCP flags). Reached through the session. */
get profileManager(): AppDataManager {
return this.session.app.profileManager;
}

/** See `SettingsBranch` for how this class relates to `PortSettingsData`. */
private readonly branch = new SettingsBranch<PortSettingsData>(
'settings.portSettings',
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/src/model/Settings/RxSettings/RxSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeAutoObservable } from "mobx";
import { z } from "zod";

import type { AppDataManager } from "src/model/AppDataManager/AppDataManager";
import type { Session } from "src/model/Session/Session";
import type { RxSettingsData } from "src/model/AppDataManager/DataClasses/RxSettingsData";
import { SettingsBranch } from "../SettingsBranch";
Expand Down Expand Up @@ -159,11 +158,6 @@ export default class RxSettings {

session: Session;

/** App-wide data (presets, MCP flags). Reached through the session. */
get profileManager(): AppDataManager {
return this.session.app.profileManager;
}

/** See `SettingsBranch` for how this class relates to `RxSettingsData`. */
private readonly branch = new SettingsBranch<RxSettingsData>(
'settings.rxSettings',
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/src/model/Settings/TxSettings/TxSettings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { makeAutoObservable } from 'mobx';
import type { AppDataManager } from 'src/model/AppDataManager/AppDataManager';
import type { Session } from 'src/model/Session/Session';
import type { TxSettingsData } from 'src/model/AppDataManager/DataClasses/TxSettingsData';
import { SettingsBranch } from '../SettingsBranch';
Expand Down Expand Up @@ -57,11 +56,6 @@ export default class TxSettings {

session: Session;

/** App-wide data (presets, MCP flags). Reached through the session. */
get profileManager(): AppDataManager {
return this.session.app.profileManager;
}

/** See `SettingsBranch` for how this class relates to `TxSettingsData`. */
private readonly branch = new SettingsBranch<TxSettingsData>(
'settings.txSettings',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export class Macro {
* settings modal can surface invalid-regex feedback in red.
*/
get rxMatchRegex(): RegExp | null {
const key = `${this.rxMatchPattern}${this.rxMatchCaseSensitive ? 'c' : 'i'}`;
const key = `${this.rxMatchPattern}\u0000${this.rxMatchCaseSensitive ? 'c' : 'i'}`;
if (this._rxMatchRegexCache !== null && this._rxMatchRegexCache.key === key) {
return this._rxMatchRegexCache.regex;
}
Expand Down
Loading
Loading