Skip to content

Bind script sharing to the AI recipient and harden DB viewer writes - #781

Merged
Sev7eNup merged 4 commits into
mainfrom
fix/audit-ai-dbviewer
Nov 3, 2026
Merged

Sev7eNup merged 4 commits into
mainfrom
fix/audit-ai-dbviewer

Conversation

@Sev7eNup

@Sev7eNup Sev7eNup commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Fourth of five stacked PRs (on top of #780). Until the earlier ones are merged this diff also shows their commits; the change of its own is the top commit.

What changes

  • Script consent bound to the recipient. GET /api/ai/knowledge/capabilities returns scriptContextRecipientKey for privileged users. The prompt dialog keeps the "share current script" consent only for that key and drops it when the key changes. generate-script takes expectedRecipientKey; when the script is shared and the key no longer matches the active profile, ScriptGenerationService throws RecipientChanged before a client is created and the API answers 409 LLM_RECIPIENT_CHANGED. The editor reopens the dialog and refreshes capabilities.
  • The key comes from the new LlmHistoryContext.Key (profile id, endpoint, model, sharing switch). The workflow and knowledge assistants derive their history context from it too, replacing two separate hash formulas; the workflow assistant now also drops history on a model change. Docs updated accordingly.
  • Database viewer: a write runs only with the typed phrase, also when Run/Ctrl+Enter is pressed again while the confirmation is open. The confirmation is a real modal with a focus trap.
  • Chat persistence: session storage goes through a wrapper that never throws into the send path; the persisted history is capped by size (newest threads and messages first) and a notice tells the user when storage is unavailable or trimmed.

Not included

The recipient-bound history replay changes from the audit branch (contextBoundHistory, knowledge-chat history slicing) belong to #674, which was already fixed by #740, and are left out.

Tests run locally

  • dotnet test tests/NodePilot.Ai.Tests (844)
  • dotnet test tests/NodePilot.Api.Tests --filter AiController|AiKnowledgeController|AiChatController|LlmProfileDefaults|AiStream (76), including the new 409 case
  • dotnet test tests/NodePilot.Cli.Tests --filter ApiDtoParity (8)
  • Vitest: AiPromptDialog, ScriptEditorDialog, useAiScriptStream, dbviewer, chat stores, ai/common components, i18n (19 files, 201 tests)
  • tsc -p tsconfig.app.json --noEmit, ESLint on the touched files

Closes #688
Closes #691
Closes #701

🤖 Generated with Claude Code

Sev7eNup and others added 4 commits November 3, 2026 17:24
Renaming an output variable now rewrites every reference through one
traversal (templates in any field, dynamic machine/credential bindings,
breakpoint conditions, decision cases and edge conditions). Copy, paste
and duplicate allocate a fresh alias per copy and rewrite the copy's own
references. The server rejects two active nodes with the same alias,
case-insensitively, and ignores disabled nodes when indexing aliases.

Inserting an activity on a conditional edge keeps the guard in front of
the new activity. Command-palette edge deletion goes through the normal
delete command, and property edits snapshot history before the first
change of a typing burst. Clipboard copies also mask recognised secrets
in edge data and string arrays.

Closes #689, #703, #693, #694, #595. Refs #574.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A save, lock change, publish or run started for one workflow no longer
acts on another workflow opened before it finished: mutations carry the
workflow id they were started for, and completions check the editing
session through the new useAsyncIdentity hook plus the draft generation
in useWorkflowPersistence.

The CRUD editors (credentials, machines, users, global variables,
maintenance windows, custom activities, alerting rules and policies) and
the admin settings sections lock the form while a save is pending and
ignore a late success for a record that is no longer open.

Closes #692, #690.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Property panels follow undo and restored drafts: an edge resyncs its
condition mode and switching to the simple condition clears the
expression; the agent host list adopts restored values. Text-file delete
can select line-range and pattern mode, waitForCondition stores the
displayed portOpen default 443 and flags a missing host or port, and
scheduledTask registration accepts only built-in or managed service
accounts, matching the ServiceAccount logon type the engine uses.

The run-history step details label the shown configuration as the
current draft and show the recorded target machine. The SCCM/AD demo
fixture uses braced interpolation; the example-script harness now parses
every demo fixture script.

Closes #695, #601, #702, #705, #603, #698.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Script generation sends the editor content only to the recipient the
user approved: capabilities expose a recipient key per active profile
(profile id, endpoint, model, sharing switch), the dialog keeps consent
only for that key, and the server rejects a stale key with
409 LLM_RECIPIENT_CHANGED before creating a client. The workflow and
knowledge assistants derive their history context from the same key.

The database viewer runs a write only after the confirmation phrase,
also when Run is pressed again while the dialog is open; the dialog is
a modal with a focus trap. Chat persistence no longer interrupts
sending when browser storage is blocked or full, keeps the newest
history within a size budget and tells the user what survives a reload.

Closes #688, #691, #701.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines +196 to 200
if (!dict.TryAdd(variable, node.Id))
throw new InvalidOperationException($"Duplicate active output variable '{variable}'.");
}
}

@Sev7eNup
Sev7eNup merged commit 10eab21 into main Nov 3, 2026
17 checks passed
@Sev7eNup
Sev7eNup deleted the fix/audit-ai-dbviewer branch November 3, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants