* fix(ai): keep surrogate pairs whole when truncating model context
Head/tail truncation sliced strings by UTF-16 code unit, so a cut could
split an emoji into a lone surrogate. JSON.stringify then emits a
`\udXXX` escape that strict providers reject ("lone leading surrogate in
hex escape"), and because the same cut is reapplied every step, the chat
stays stuck on that 400 for every later request.
- Add textBoundaries helpers (sliceHead, sliceTail, safeSliceBounds) and
use them at every truncation site on the model request path.
- Wrap provider models with a middleware that replaces any remaining lone
surrogate with U+FFFD before the request body is serialized.
* fix(ai): keep own __proto__ keys when normalizing prompt values
toWellFormedValue cloned changed objects by plain assignment, so an own
__proto__ key (e.g. from JSON.parse) hit the inherited setter: the field
was dropped from the request and the clone's prototype changed. Clone
with the source prototype and define own properties instead.
* fix(ai): persist AI sessions per record in IndexedDB instead of a 2MB localStorage blob
Closes#4123.
The legacy store serialized every session into one localStorage JSON key
under a 2MB byte budget. Each write re-serialized the whole store, and the
degradation ladder dropped whole oldest sessions when the budget was
exceeded — silently destroying capped chats (~1MB each) on every write.
- add aiSessionIdbStorage: db netcatty_ai_sessions, one record per session
(keyPath id) plus a meta store (schemaVersion, lastWriteAt, mirrored
active-session map); BroadcastChannel replaces the localStorage storage
event for cross-window sync
- one-time boot migration from netcatty_ai_sessions_v1; the legacy key
stays untouched for one release as a read-only fallback
- writeSessionsForStorage now diffs against the last persisted set and
writes only changed records through a serialized queue; the 2MB budget
and its degradation ladder are removed (the global re-serialization cost
they defended no longer exists)
- retention becomes a pure session-count cap (raised 50 -> 1000); the
per-session 200-message cap is unchanged
- when the cap evicts sessions, a pre-eviction backup generation is
written before the records are dropped, closing the #4018 mirror blind
spot; explicit deletions and cloud-authoritative removals do not
trigger it
- boot restore chain: IndexedDB -> legacy localStorage (migration) ->
#4018 disk backup generations; a corrupt/unavailable IndexedDB falls
back to legacy localStorage writes
- tests: IDB roundtrip/migration/active-map mirror via a minimal fake
indexedDB, per-record put/delete diffing, count-cap eviction with
pre-eviction generation, explicit-delete suppression, synced-history
no-prune, corrupt-IDB fallback; byte-ladder tests removed with the
ladder
* test(ai): update fork/undo reload tests to the IndexedDB persistence contract
Issue #4123: session persistence moved to IndexedDB per-record writes; the
persisted set no longer lands in the legacy localStorage key (read-only
fallback for one release) and the retention cap is a session count of 1000
instead of 50.
- fork/undo reload tests read the persisted set via
getPersistedAiSessionsSnapshot() instead of parsing localStorage
- cap-boundary assertions (49/50 newer chats) become preservation
assertions (newerCount + 2 records survive; the 1000-cap boundary is
covered by aiStateSnapshots.test.ts)
- the reload step seeds the read-only legacy store with the persisted set,
the stand-in for what the migration persists on a profile without
IndexedDB
* feat(ai): make the per-session message cap user-configurable
* fix(ai): sequence session sync after boot hydration
Cloud-sync collection (collectAiSessionsForSync) could run before the
IndexedDB boot hydration settled and writeSessionsForStorage() the stale
legacy localStorage list over newer per-record IndexedDB data. The
collection now skips the sync round until the boot load settles; the next
auto-sync picks up the hydrated store.
The hydration signal lives in aiStateSnapshots (isAiSessionsHydrationComplete
/ markAiSessionsHydrationComplete) and is shared with useAIState's boot
effect and the cross-window refresh handler.
* fix(ai): make the legacy session migration one-shot via a persisted marker
The migration keyed on 'IndexedDB empty + legacy populated'. Because the
legacy key is intentionally kept for one release as a read-only fallback,
any boot whose store was empty re-ran the migration and resurrected chats
the user had deleted (P1②).
A migrationCompleted marker is now persisted in the meta store after the
migration data is durable. Once present, the legacy key is never consulted
again: an empty store is authoritative. The marker also records a store
that was already populated by a pre-marker build, and an uninitialized
empty store, so 'intentionally empty' is distinguishable from 'uninitialized'.
* fix(ai): harden boot persistence failure paths
Four review findings around the boot load's failure modes:
- P2①: when IndexedDB fails at boot and sessions come from the legacy
store, the diff baseline was seeded even though nothing was persisted,
so a later edit diff-wrote only the edited record and the rest were
lost after recovery. The legacy set is now persisted best-effort (one
re-open retry) before seeding; if that fails the baseline stays unset
so the next edit rewrites every record.
- P2②: the active-pointer validation effect ran against the
initially-empty in-memory session array and nulled every pointer
before the async load finished. It now waits for the hydration signal.
- P2③: when IndexedDB stayed unopenable and the legacy store was
missing/corrupt, the unconditional recheck threw into the swallowing
outer catch and the #4018 disk backup was never applied. The recheck
failure is now contained (one retry already happens inside open()),
the newest backup generation is applied as the recovery source, and
the error is surfaced via console.warn.
- P2④: a cross-window empty getAll (another window deleted the last
chat) hit an early return, kept the deleted session alive locally and
resurrected it on the next edit. After hydration an empty store is
adopted; the early-return only covers the pre-hydration window.
Scenario regression tests live in useAIState.bootHydration.test.ts;
fakeIndexedDb gains failOpenTimes for counted open failures.
* fix(ai): gate session maintenance and migrate legacy overflow history
* fix(ai): skip backup restore of empty IDB and resume failed overflow migration
* ci: retrigger lint-and-test after runner shutdown
The previous Actions runner received a shutdown signal during plugin-contract
verification; lint had already passed and unit tests never started.
---------
Co-authored-by: GOUKI9999 <GOUKI9999@users.noreply.github.com>
Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
* perf(renderer): cut the startup bundle by a third
Every window parsed ~6.1 MB of JavaScript before the first render. The entry
chunk carried all five UI locales, and the whole AI SDK chunk was preloaded
even though the AI panel is lazy.
- i18n: only English stays in the entry; other dictionaries load on demand
(plus their same-base fallback, e.g. zh-TW -> zh-CN). index.tsx awaits the
saved language before the first render, and I18nProvider re-renders when a
runtime switch finishes loading.
- AI runtime: aiStateSnapshots cleaned up chats through getAgentRuntime(),
and the plugin AI/agent hosts created their runtimes on mount, which pulled
the Catty harness and @ai-sdk providers into startup. Cleanup now goes
through a light handle that the runtime registers (the reversible privacy
flag and main-process privacy mapping are still cleared without a runtime),
and both plugin hosts create their runtime on the first request, re-checking
liveness after the async load.
- Chunking: manualChunks' object form also moved Vite's dynamic-import
preload helper into vendor-ai (the AI SDK itself uses import()), so the
entry imported it from there and vendor-ai (649 KB) was preloaded on every
launch. Vendor chunks now use the function form and the helper gets its own
1 KB chunk.
- jsqr is loaded when a QR image is imported instead of with the host editor.
- startupBundle.architecture.test.ts guards these invariants.
Startup JS (index.html): 5.29 MB entry + 649 KB vendor-ai + 138 KB radix ->
3.80 MB entry + 1 KB helper + 174 KB radix (-35%). Startup harness, 2000 hosts,
10 runs, warm p50: loadURL -> renderer entry evaluated 321 -> 207 ms,
loadURL -> renderer ready 481 -> 323 ms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(i18n): preload locale messages before static rendering
* test(i18n): preload locales in remaining zh-CN UI tests
Non-English dictionaries now load lazily, so I18nProvider can initially render English before its effect finishes loading zh-CN. Explicitly await loadLocaleMessages before rendering these localized UI tests to fix the remaining CI failures without timing-based waits or production changes.
* chore: retrigger CI after locale preload fix
Previous tip 38108ce66 was on the branch but the PR head stayed
stuck on d49ad024e after a GitHub 500 during push. Empty commit
to refresh the PR head and re-queue checks.
* chore: retrigger CI after plugin-contract runner cancel
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf: add opt-in startup timeline and real-app startup harness
- electron/perfTrace.cjs records first-occurrence startup marks in the main
process when NETCATTY_PERF_TRACE=1 (a no-op otherwise), then writes the
main-window renderer timeline (navigation, paint, netcatty:* marks, JS heap)
and app.getAppMetrics() to JSON after the first renderer-ready signal.
- Marks: main.cjs entry / modules loaded / whenReady, main window creation,
registerBridges and plugin-host start/end, loadURL, did-finish-load,
renderer ready, window shown. The renderer adds three performance.mark()
calls (entry evaluated, App mounted, renderer ready), also visible in
DevTools.
- scripts/perf-startup.live.cjs (npm run perf:startup) launches the built app
N times against a throwaway --user-data-dir profile with ssh:// deep-link
registration disabled, optionally seeds synthetic hosts over CDP, and
reports cold plus warm p50/p90.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(harness): add --profile option to reuse a startup profile
Lets the harness keep one profile across invocations, e.g. to compare warm
V8 code caches across builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore: retrigger CI after flaky monitorRuntimeIsolation failure
Previous lint-and-test failed on known-preexisting
`useEffect is not defined` in monitorRuntimeIsolation.test.ts.
* chore: retrigger CI after monitorRuntimeIsolation useEffect flake
Known pre-existing flake: monitor controls test fails with
`useEffect is not defined`. Empty commit to re-run once.
* test(app): bind React hooks in monitorRuntimeIsolation VM sandbox
Extracting component declarations drops their React imports, leaving bare hooks such as useEffect undefined in the VM. Inject common React hooks and APIs while preserving explicit binding overrides to prevent intermittent monitor isolation failures in CI.
Stub the startup performance mark through App test bindings so the mount effect can execute without browser globals. Production components remain unchanged.
Validation: monitorRuntimeIsolation passed five consecutive runs. Plain npm run lint found 17 existing errors in git-ignored scratch files; excluding only _t.mjs and sim-4107.mjs passed with zero errors and eight existing warnings.
* chore: retrigger CI after plugin-contract runner cancel
Lint/schema passed; plugin-contract step cancelled by the runner
(not a test failure). Empty commit to re-queue.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
* chore: fix outstanding ESLint warnings
- useSftpFollowTerminalCwd: drop activeSessionId/focusedSessionId from the
syncFollowToTerminalCwd deps; the callback reads them through refs and the
only consumer effect already re-runs on those ids.
- useSftpPaneDialogs: list the stable setShowDeleteConfirm callback in the
handleDelete/openDeleteConfirm deps.
- csvProxy: remove the unnecessary `\[` escapes inside character classes
(same matches under the `u` flag).
- Remove unused test imports/variables.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore: retrigger CI after runner SIGTERM cancel
Previous lint-and-test was cancelled by runner shutdown, not a real failure.
* chore: retrigger CI after second runner cancel
Lint had already passed; plugin-contract step was cancelled by the runner.
* chore: retrigger CI after third runner cancel
Lint and schema steps passed; plugin-contract step was cancelled by
the runner again. Empty commit to re-queue lint-and-test.
* chore: retrigger CI after repeated runner cancel
plugin-contract step keeps being cancelled by the Actions runner
(not a test failure). Empty commit to re-queue; Actions rerun API
denied for this PAT.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
* perf(terminal): stop per-second churn while connecting and while idle
- Connecting sessions: the 200 ms progress animation and 1 s countdown were
Terminal state threaded into the TerminalView ctx, so every connecting
session (hidden tabs and startup restores included) re-rendered Terminal +
TerminalView up to six times a second. Terminal now only publishes the
timeout deadline and real progress events; the connection dialog animates
and counts down locally (connectionTicker.ts). HostConnectionTestDialog
keeps passing progress/timeLeft as before.
- Monitor runtime: polled every second unconditionally and woke every
subscriber each time because takenAt always changes. It now polls at 1 s
only while something is monitored (here or in another window), 10 s
otherwise, and skips notifying for unchanged idle replies.
- Auto-reconnect progress log: capped at the newest 300 lines (it grew by a
few lines every 5 s retry for as long as an outage lasted).
- App Lock: report activity at most once a second instead of an IPC per
keystroke / wheel tick / pointer event.
- Tray/Dock: the renderer resends hosts only when the host list changed, and
the main process rebuilds the macOS Dock menu (sort + one native item per
host) only then, not on every session status change.
Real app, profiling build, main -> this change:
3 SSH sessions connecting (3 s) 14 commits / 35.3 ms -> 8 / 1.7 ms
idle (10 s) 13 commits / 3.1 ms -> 2 / 0.1 ms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(terminal): update observe-popup reconnect deps assertion for capped progress logs
CI failed because #4118 wrapped setProgressLogs in useCallback to apply
capConnectionProgressLogs and added it to scheduleAutoReconnect deps.
The observe-popup source assertion still expected the old deps list.
The attachExistingSession early-return behavior is unchanged; only the
stale dependency regex needed updating.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* perf(terminal): cap live WebGL contexts and stop the context-loss cascade
Chromium keeps at most 16 WebGL contexts per renderer and force-loses the
one that drew least recently past that. Hidden terminal panes keep their
WebGL renderer unless hibernation is on, so with more than 16 terminal
tabs every forced loss was rebuilt 50 ms later, evicting another context.
With 20 local tabs, half of all tab switches landed on a lost context
(xterm waits 3 s before falling back), and terminals that lost three
contexts within a minute were parked on the DOM renderer for good.
- Add a shared context budget (12). Past it, renderers of panes hidden for
at least 3 s are released, least recently seen first. Visible panes are
never released or refused; a released pane rebuilds when shown.
- A context lost while hidden waits for the reveal instead of rebuilding
at once, and no longer counts toward the breaker.
- The short-hide CSS reveal path now also asks for the renderer (a no-op
while it is live).
- Disposing the addon left its context alive until GC. Lose it explicitly
so GPU memory and the Chromium slot come back right away.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(notes): bound the source editor's undo history
Every undo step in the markdown source editor holds a full copy of the
note, and the stack never shrank. A long session on a large note kept
every intermediate version alive (a 100 KB note with 1,000 steps holds
~200 MB of UTF-16 text).
Keep the 200 most recent steps and at most 8M characters across them,
dropping the oldest first. The newest step always survives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Several everyday interactions re-rendered the entire shell (AppView, TopTabs,
TerminalLayer and every pane) even though nothing they show had changed:
- Clicking or focusing a split pane always replaced the workspaces array
(twice per click: onClick + onFocusCapture), cascading through the whole
app and re-saving the session restore snapshot. setWorkspaceFocusedSession
and moveFocusInWorkspace now keep the same array when focus is unchanged
(domain/workspace.ts setWorkspaceFocusedSessionId).
- Every window focus/visibility change resynced app lock and produced a new
runtime state object even when nothing changed, re-rendering the provider
tree. Equal states keep the current object and useAppLockState's result is
memoized.
- Quick switcher keystrokes went through AppSideEffects state and the
app-local UI store, re-rendering AppSideEffects, every host island, AppShell,
AppView and TopTabs per character. QuickSwitcherOverlay now owns the query
and host results; the overlay unmounts on close, which resets the query
exactly where setQuickSearch('') used to.
- Pressing/releasing Ctrl/Cmd (every ⌘C/⌘V/Ctrl+C) re-rendered the whole tab
bar to toggle shortcut number badges. The held flag now lives in a small
store read only by each tab's TabIconSlot.
- AppView passed fresh inline callbacks that defeated TopTabs' memo comparator
and every open editor tab; TextEditorTabView is now memoized. TopTabs
memoizes per-workspace session lists and hoists the root tab icons.
- Workspace drag previews only update state when the drop hint actually moves.
React commits / render time for 10 repetitions in the real app (profiling
build, 2 split panes, 300 hosts), main -> this change:
window focus 42 / 17.1 ms -> 2 / 0.4 ms
press/release Cmd 50 / 41.9 ms -> 22 / 6.6 ms
click focused pane 42 / 69.6 ms -> 3 / 0.4 ms
quick switcher typing 41 / 61.3 ms -> 16 / 34.8 ms
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes#4107.
Merge gate: GitHub Codex clean on tip b7efbe347; local CLEAN residual (unknown colon-prefixed alt-screen challenges) left as documented thrash; CI green (lint-and-test / windows-fido / windows-broadcast-ssh); Electron smoke PASS NC_OUT=/workspace/netcatty-smoke-shots/pr-4109-b7efbe347-20261104-122316 (both panes exited vim via toolbar broadcast :q!).
* fix(terminal): honor Settings custom shell when Terminal button clicked (#4085)
Vault/host-tree Terminal buttons wired onClick={handler}, so React passed the
MouseEvent as the shell arg and skipped resolveShellSetting(terminalSettings.localShell).
Only treat objects with a string command as explicit shells; wrap onClick sites.
* ci: retrigger after lint-and-test runner cancel (#4085)
* test(terminal): accept wrapped local-shell onClick in host-tree toolbar (#4085)
Codex GH review: source assertion still expected onClick={onCreateLocalTerminal}
after wrappers; update to () => onCreateLocalTerminal() so npm test passes.
* fix(terminal): forward xterm onBinary for legacy mouse (#3811)
Legacy DEC mouse (ttymouse=xterm2) is emitted via onBinary; only onData
was wired. Preserve 0-255 through the write path with a binary/latin1
Buffer so high coordinate bytes are not UTF-8-corrupted.
* chore: retrigger CI after lint-and-test runner shutdown (exit 143)
* chore: retrigger CI after lint-and-test runner shutdown (2)
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Contributor GOUKI9999 session_reconnect/session_recover. Maintainer gate fix: do not report ready while still offline/connecting (pending instead); connected keeps advisory shellReady; regenerate capability tool specs. Unit tests 12/12. Electron smoke PASS (SSH shell path). Residual P2 hung-worker readiness left timeout-bounded. No release.
* feat(monitor): 优化磁盘IO展示与系统分区告警 [4030]
* fix(monitor): 修复磁盘监控评审问题 [4030]
* fix(monitor): align Partitions bars with Memory; hide bare / label
Label-above-bar for partition list; single-root `/` hides the label and
centers the bar like Memory/CPU (unchanged). Multi-disk keeps top align +
system alerts. Disk IO adds a spacer row to track usage labels.
Review crops under .github/review/ for PR discussion (drop before merge OK).
* fix(monitor): keep bare-/ align; multi-disk labels stay left
Address Chris density feedback: keep the single root label hidden and vertically centered with Memory, and restore side-by-side labels for multiple disks. Remove the Disk I/O spacer and update the review crops.
* chore(monitor): drop PR #4031 discussion review crops
---------
Co-authored-by: wendeng.dong <wendeng.dong@sailuntire.com>
Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
Move infrequent Tool Access / MCP / privacy / HTTP setup into focused dialogs; keep status and clear actions on the main page. Rebased onto current main after locale/settings conflicts.
Codex CLEAN (gpt-6.1-terra). CI lint-and-test green. Focused privacy/MCP/guidance tests passed on rebase tip. No release.
Gate ModelSelector discovery on settled error; preserve explicit Refresh and config resets. Component regressions included.
Codex CLEAN (gpt-6.1-terra) vs main. CI green on tip. No release.
* fix(ai): keep dropped AI chats recoverable with dangling marking and /rebind
Closing a member terminal or dissolving a workspace used to clear the
chat's active pointer, making it invisible (scope rank 0) and
unrecoverable from the UI even though the record survived in storage.
- orphan cleanup now marks dropped chats `scopeDangling: true` and keeps
record + active pointer intact; the flag clears when the target
returns or the chat is rebound
- `/chats` lists dangling chats with a numbered inline affordance and
hint line
- new `/rebind <n>` panel action rewrites `scope` to the panel's current
scope, clears the marker and restores the active pointer
- i18n keys added for en / zh-CN / zh-TW / es / ru
Stacked on #4018. Refs #4015 (R2).
* fix(workspace): reuse existing workspace id when merging tabs with a workspace
createWorkspaceFromSessions silently no-opped when either merged tab
already belonged to a workspace (e.g. dragging a workspace pane onto a
standalone terminal), and the older dissolve->recreate behavior
regenerated the id that workspace-scoped AI chats bind to.
When one of the merged tabs has a workspace, the orphan tab now joins
that existing workspace (pane inserted next to the anchor session, tab
slot collapsed), so workspace-scoped chat bindings survive. Merging two
standalone tabs still creates a fresh workspace.
Stacked on #4018. Refs #4015 (R3).
* fix(ai): persist cleaned active map on dangling chat rebind
rebindSessionScope was updating React state to drop stale old-scope
pointers, then rebuilding localStorage from the pre-rebind snapshot and
resurrecting them. Persist the same cleaned map via rebindActiveSessionMap.
* fix(ai): persist rebind map inside setState; wire backup actions on terminal panel
- Write cleaned active-session map from inside the rebind updater so a
deferred React setState cannot skip snapshot/localStorage persistence.
- Pass exportSessionsBackup/importSessionsBackup through TerminalLayerSupport
and include them in AI_CHAT_SIDE_PANEL_AI_STATE_KEYS so history-drawer
backup buttons work on the normal terminal path.
* fix(ai): guard backup restore races and use app-wide live targets for /chats
- Skip restore when in-memory sessions already exist; apply snapshot,
storage write, and AI state emit atomically inside the empty-state path
so peer useAIState instances see the restore.
- Thread validAIScopeTargetIds into AIChatSidePanel as liveScopeTargetIds
so /chats does not mark chats bound to other open terminals as dangling.
* fix(ai): open rebound chat in panel view and refresh /chats listing
- rebindSessionScope also sets the panel view to the rebound session so an
existing draft/other chat does not keep hiding the recovery.
- After /rebind, rewrite the stored listing instead of rebuilding from the
stale render so the chat is no longer offered as dangling.
* fix(workspace): invert join split when dragged pane owns workspace; refresh /chats titles
- When merging a workspace-owned dragged pane onto a standalone tab, the
orphan is inserted — invert the drop position so the previewed side matches.
- Compare workspaces in AIChatSidePanel memo so /chats picks up renames.
* fix(ai): validate live sessions array on boot; mark imported orphans dangling
- Reject parseable non-array store values (e.g. {}) via readLiveSessionsArray
so boot restore is not blocked by a corrupt-but-truthy value.
- After manual import, re-run orphan cleanup with the last known live target
set so chats bound to closed scopes become dangling and /rebind-able.
* fix(ai): merge imported sessions before orphan cleanup
Apply import merge to the snapshot/ref synchronously, then run dangling
marking, so a deferred setState cannot let cleanup rewrite over the import.
* fix(ai): mark restored/imported orphans dangling even with no live targets
Restore and import do not change live terminals/workspaces, so the orphan
cleanup effect will not re-run. Always call cleanup against the last known
live target set after those paths — an empty set is a valid observed state
(nothing mounted), not an unavailable snapshot — so chats bound to missing
scopes become dangling and /chats can offer /rebind.
* fix(ai): apply backup restore synchronously before dangling cleanup
Do not gate restore + orphan marking on a setState updater having run.
A deferred updater left didRestore false, skipped cleanup, and could leave
restored chats with missing scopes unmarked and unrebindable from /chats.
* fix(ai): complete /rebind from a partial slash picker selection
Selecting Rebind after typing `/re` left the composer unchanged, so a
following number became `/re 1` and could be sent to the agent. Replace the
slash query with `/rebind ` the same way Rename does.
* fix(ai): replace hostIds on rebind; skip non-array backup generations
- Rebind builds a fresh destination scope (including hostIds from the
panel) instead of spreading the old scope, so history matching follows
the new terminal/workspace host.
- readLatestGeneration treats valid JSON that is not a session array as
unusable and continues to older generations, matching corrupt skips.
* fix(ai): revalidate dangling chat before /rebind from stale /chats listing
Skip rebind when the cached entry is deleted or already bound to a live
scope; drop stale listing entries so a second panel cannot steal the chat.
* fix(ai): reject malformed /rebind numbers
Require the entire trimmed argument to be digits so /rebind 1foo and
/rebind 1.5 show usage instead of silently targeting index 1.
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
* feat(ai): add /rename and /chats slash commands plus a session durability layer
Panel slash commands (#4015 feedback):
- /rename <title> renames the current chat via updateSessionTitle; the
command is intercepted in ChatInput's system-command branch and never
reaches the agent. Empty title shows a usage hint. The history drawer
gains an inline rename affordance.
- /chats renders a dismissible system-style note listing the panel's
visible chats (title / agent backend / workspace-or-terminal scope with
a dangling marker / relative last-active time; current chat marked).
Deliberately not named /resume: session.resume already means
flow-recovery-after-cancel. Listing logic is pure (aiChatsListing.ts)
so a future rebind action can attach per-entry actions.
- i18n keys added for en/es/ru/zh-CN/zh-TW.
Durability layer (additive; cleanup/eviction semantics untouched):
- Every successful store write schedules a debounced (~2s) mirror of the
exact persisted JSON to {userData}/ai-sessions-backup/ through a new
aiSessionsBackupBridge: atomic temp+rename writes, 5 rolling
generations, timestamped names.
- On boot, a missing/empty live store is restored from the newest
parseable backup generation. The asymmetry is deliberate: empty ->
restore, non-empty -> leave alone, so restored data can never
resurrect explicitly deleted chats.
- Manual export/import in the history drawer via real file dialogs
(fixed-path fallback where dialogs are unavailable); import merges by
id with newer updatedAt winning.
Tests: bridge rotation/corruption/rejection, restore decisions, merge
semantics, debounce throttle, mirror-on-write, slash interception and
/chats listing seams. eslint clean; tsc unchanged vs baseline.
* fix(ai): repair sessions backup IPC and restore/import guards
- Forward write/export payloads through preload unchanged so the main
bridge receives a string json (was double-wrapped → invalid-json).
- Restore from disk only when the live store is missing or corrupt;
treat a valid [] as an intentional clear. Flush the debounced mirror
on beforeunload so deletions land before quit.
- Require id + messages[] + finite updatedAt when parsing backup/
import entries so malformed objects cannot reach pruneSessionsForStorage.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): complete /rename from partial slash and harden import shape
- Selecting Rename from the slash picker replaces the active slash token
with `/rename ` so a following title is intercepted, not sent to the agent.
- parseBackupSessions also requires title, agentId, and a scope object with
a string type before accepting an imported/backup entry.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): validate backup messages and skip prune on synced restore
- Drop backup/import sessions whose messages lack id/role/timestamp.
- When cloud AI-session sync is enabled, restore parsed sessions without
pruneSessionsForStorage so local retention cannot truncate synced history.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): export prepareRestoredSessions helper
Missed in the previous commit; required by useAIState boot restore and tests.
Co-authored-by: Netcatty Maintainer <binaricat@users.noreply.github.com>
* fix(ai): require message content on backup import; raise disk cap to 64MB
* fix(ai): normalize corrupt sessions store to [] before boot restore
* fix(ai): skip non-array backup generations when reading latest
* fix(ai): emit sessions change on backup restore; skip unusable gens
* fix(ai): treat empty backup gen as wipe; align gen usability with parser
* fix(ai): seed backup on boot for live store; report durable import count
* fix(ai): emit sessions change after backup import
* docs(ai): clarify sessions backup recovers in-profile store only
---------
Co-authored-by: binaricat <binaricat@users.noreply.github.com>
Reuse the selection-token snapshot comparison for list and install, including a rejected stale or withdrawn selection. Preserve synchronous unavailable-source validation before the asynchronous list operation. The loaded-row regression rejects installation without downloading or executing a package.
Apply the exact six-file patch from implement_plugin_row_layout, based on 0c05a96fa1. Patch SHA-256: 5c58150fc3a7f72169b1a23ad1410cf37c51051b29bd6600bf30e848a9f366d6. Native visual acceptance remains pending.