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
29 changes: 29 additions & 0 deletions src/components/shared/WindowShell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Icon from '../ui/Icon.svelte'
import { paneLocks, togglePaneLock } from '$lib/ui/paneLocks.js'
import { edgeFade } from '$lib/ui/edgeFade.js'
import { registerPanes } from '$lib/windowPanes.js'

// 197: reusable window CHROME. A MAIN area flanked by a collapsible PRIMARY
// sidebar and a SECONDARY panel that can show one of several MODES (e.g.
Expand Down Expand Up @@ -183,6 +184,34 @@
persistSecondary()
if (narrow && narrowMode) narrowPane = 'main'
}
// 107-panels: the assistant's show {state: collapse | expand, pane} works these same panes ($lib/windowPanes)
$effect(() =>
registerPanes(key, {
status: () => ({
primary: { available: !hidePrimary && !!primary, open: narrow ? pane === 'primary' : primaryOpen },
secondary: { available: secondaryModes.length > 0 && !!secondary, open: narrow ? !!narrowMode : secondaryOpen, mode: secondaryMode },
locked,
narrow
}),
setPrimary: (open: boolean) => {
if (narrow) {
narrowPane = open ? 'primary' : 'main'
return
}
primaryOpen = open
writePanelOpen(`ws:${key}:primaryOpen`, primaryOpen)
},
setSecondary: (open: boolean) => {
if (narrow) {
narrowPane = open ? secondaryMode : 'main'
return
}
secondaryOpen = open
if (open) secondaryPinned = true
persistSecondary()
}
})
)
export function secondaryStatus() {
if (narrow) return { open: !!narrowMode, mode: narrowMode ?? secondaryMode, pinned: secondaryPinned, narrow: true }
return { open: secondaryOpen, mode: secondaryMode, pinned: secondaryPinned }
Expand Down
402 changes: 402 additions & 0 deletions src/lib/ai/panels.js

Large diffs are not rendered by default.

216 changes: 216 additions & 0 deletions src/lib/ai/panelsCore.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/lib/ai/personToolNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ export function personToolReads(name, args) {
const action = String(args?.action ?? '');
if (name === 'files') return action === 'list' || action === 'read';
if (name === 'scene') return action === 'list';
// 107-panels: the panel registry with each panel's state
if (name === 'show') return action === 'panels';
return false;
}
31 changes: 23 additions & 8 deletions src/lib/ai/personTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ const FILES_DESCRIPTION =
'Not for scenes (scene opens them) or for the scene\'s objects (list_scene).';

const SHOW_DESCRIPTION =
"Show the person something on THEIR OWN screen (never anyone else's): panel = open, close or bring forward one of their panels " +
'(Explorer, Objects, Inspector, Flow editor, Code, Timeline, Assets, Preview, Chat, Assistant); camera = move their editor view to frame objects ' +
'(frame: [uuids], select: true also selects them), to a position + target, or let them look through a scene camera (through: uuid); ' +
"Show the person something on THEIR OWN screen (never anyone else's). " +
'panels = the list of every real panel (id, title, what it contains, read-only or not) with its state now: open, where (dock, left, right, floating, window), visible and front; ' +
'also the dock and the two sidebars, focus mode, the saved layouts, and the refused surfaces by reason. It only reads and never asks. ' +
'panel = open, close, focus (bring to the front where it is), toggle, move (to: dock, left, right, floating), maximize / restore (a docked panel fills the window), ' +
'collapse / expand one of its own sidebars (pane) for one panel by its name: Explorer, Objects, Inspector, Configure Scene, Flow editor, Animation, Timeline, UV editor, Shader editor, HUD editor, Code, ' +
'Profiler and Statistics (read-only views), Free assets, Preview (the selected Explorer file), Debugger, Chat, Assistant; or name "Dock", "Left sidebar", "Right sidebar" to open, close or toggle them (close hides, tabs stay open). ' +
'An unknown name opens nothing and the error lists the valid names: never guess another panel. The answer says visible and front truthfully. ' +
'Panels belong to Edit: while the person plays, panel and layout calls are refused (panels still reads). ' +
'layout = apply a saved layout by name, or save the current one under a new name. ' +
'camera = move their editor view to frame objects (frame: [uuids], select: true also selects them), to a position + target, or let them look through a scene camera (through: uuid); ' +
'code = open a file or a Script / Behaviour node\'s code in their Code tab at a line, selecting lines [line, to], a range, or the first match of find; ' +
'back = undo what the last show changed. The first time for each of panel / camera / code the person is asked on their screen (Always / This time / No): ' +
'call again with the confirmId; after No, do not ask again, tell them where to look instead. ' +
'Each action leaves a line with a Back button for the person. Not in a VR headset (camera moves are refused there), not while they play, drag or type; ' +
'6 calls a minute, one camera move per 2 s. Never opens sign-in, account, settings, consent, publishing, connected apps or payment. ' +
'6 calls a minute, one camera move per 2 s. Never opens sign-in, account, settings, consent, publishing or export, connected apps or payment (each refused by name, with its reason); Configure Scene (scene settings) is scene content and opens. ' +
'screenshot never moves anyone (use it to look yourself); show moves the person\'s own view. show only opens and selects code: change text with files {action: "write"}, running code with edit_behaviour. ' +
'Opening another scene is scene, not show.';

Expand Down Expand Up @@ -81,9 +88,18 @@ export const PERSON_AI_TOOLS = [
parameters: {
type: 'object',
properties: {
action: { type: 'string', enum: ['panel', 'camera', 'code', 'back'], description: 'what to show' },
name: { type: 'string', description: 'panel: Explorer, Objects, Inspector, Flow editor, Code, Timeline, Assets, Preview, Chat or Assistant' },
state: { type: 'string', enum: ['open', 'close', 'focus'], description: 'panel: default open (focus brings an open one forward)' },
action: { type: 'string', enum: ['panels', 'panel', 'layout', 'camera', 'code', 'back'], description: 'what to show (panels = the list, reads only)' },
name: { type: 'string', description: 'panel: a panel title from panels (Animation, UV editor, Profiler, ...) or Dock / Left sidebar / Right sidebar; layout: the layout name' },
state: {
type: 'string',
enum: ['open', 'close', 'focus', 'toggle', 'move', 'maximize', 'restore', 'collapse', 'expand', 'apply', 'save'],
description: 'panel: default open (with to: opens it there); focus brings an open one to the front; move needs to; collapse / expand need pane. layout: apply (default) or save'
},
to: {
description: 'panel: where to move it — dock, left, right or floating. code: with line, the last line to select',
anyOf: [{ type: 'string', enum: ['dock', 'left', 'right', 'floating'] }, { type: 'number' }]
},
pane: { type: 'string', description: 'panel collapse / expand: one of the panel\'s own sidebars (panels lists paneNames: tree, files, tools, ...)' },
frame: { type: 'array', items: { type: 'string' }, description: 'camera: object uuids to frame together' },
select: {
description: 'camera: true = also select the framed objects. code: a range to select, {from: [line, col], to: [line, col]} (lines from 1, columns from 0)',
Expand All @@ -100,7 +116,6 @@ export const PERSON_AI_TOOLS = [
node: { type: 'string', description: 'code: a Script or Behaviour node id' },
object: { type: 'string', description: 'code: an object uuid: its first Script or Behaviour node' },
line: { type: 'number', description: 'code: the line to go to (from 1)' },
to: { type: 'number', description: 'code: with line, select lines line..to' },
find: { type: 'string', description: 'code: select the first match of this text (from line, when given)' },
confirmId: { type: 'string', description: 'the answer to the first-use question (from a needsConfirm answer)' },
wait: { type: 'number', description: 'with confirmId: seconds to wait for the person\'s answer (at most 60)' }
Expand Down
108 changes: 14 additions & 94 deletions src/lib/ai/showCore.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Roadmap 104 C2 — `show`, the pure half (a LEAF: imports nothing). showTool.js drives the interface.
// Roadmap 104 C2 — `show`, the pure half (a LEAF: imports only the panelsCore leaf). showTool.js drives the interface.
//
// `show` acts on the screen of the person the assistant acts for, and nobody else's: it has no peer
// argument at all. Its eight safety rules (scout report row 7c) and where each one lives:
// 1 own tab only; headless agent pages do not get the tool (personTools.js / tpAgent)
// 2 a deny-list: never sign-in, consent, Publish, Connected apps, account, payment surfaces DENIED / deniedPanel()
// 2 a deny-list: never sign-in, consent, Publish, Connected apps, account, payment surfaces panelsCore BLOCKED / blockedReason()
// 3 the first use of each kind asks once (Always / This time / No), stored per device showTool.js + SHOW_KINDS
// 4 every action leaves a line the person can act on: "Claude moved your view · Back" showTool.js
// 5 no camera move in a headset (this release) showTool.js
// 6 reduced motion: an instant cut (flyTo's motionMs) objectActions.flyTo
// 7 6 calls a minute, one camera move per 2 s, refused while the person drags or types SHOW_PER_MINUTE / CAMERA_GAP_MS
// 8 editing text stays files {write}: show {code} only opens, goes to a line and selects (no text argument)

import { PANELS, panelOf, deniedPanel, normalName, blockedReason, BLOCKED } from './panelsCore.js';

/** the kinds the person is asked about, once each */
export const SHOW_KINDS = /** @type {const} */ (['panel', 'camera', 'code']);
export const SHOW_PER_MINUTE = 6;
Expand All @@ -24,101 +26,19 @@ export const KIND_WORDS = /** @type {Record<string, string>} */ ({
code: 'open code for you'
});

// 107-panels: the panels, their names and the refused surfaces live in ONE registry (panelsCore.js, also a
// leaf); these are the names show always exported, kept so every reader keeps working.
export { panelOf, deniedPanel, normalName, blockedReason };

/**
* The panels `show` may open, close or bring forward — the allow-list. `key` is the app's own key
* (panelToggles / dockHost), `via` how it opens.
* @type {Record<string, {key: string, label: string, via: 'toggle' | 'hosted' | 'inspector' | 'chat'}>}
* The panels `show` may open, close or bring forward, by id: `key` is the app's own key (panelToggles /
* dockHost), `via` how it opens, `label` its title.
* @type {Record<string, {key: string, label: string, via: string, readOnly?: boolean}>}
*/
export const SHOW_PANELS = {
explorer: { key: 'explorer', label: 'Explorer', via: 'toggle' },
objects: { key: 'objects', label: 'Objects', via: 'toggle' },
inspector: { key: 'inspector', label: 'Inspector', via: 'inspector' },
flow: { key: 'flow', label: 'Flow editor', via: 'toggle' },
code: { key: 'code', label: 'Code', via: 'toggle' },
timeline: { key: 'timeline', label: 'Timeline', via: 'toggle' },
assets: { key: 'assets', label: 'Assets', via: 'hosted' },
preview: { key: 'preview', label: 'Preview', via: 'hosted' },
chat: { key: 'chat', label: 'Chat', via: 'chat' },
assistant: { key: 'chat', label: 'Assistant', via: 'chat' }
};

/** other words people use for them */
const ALIASES = /** @type {Record<string, string>} */ ({
library: 'explorer',
files: 'explorer',
'file explorer': 'explorer',
outliner: 'objects',
'object list': 'objects',
hierarchy: 'objects',
properties: 'inspector',
'properties panel': 'inspector',
'node editor': 'flow',
nodes: 'flow',
'flow graph': 'flow',
'flow editor': 'flow',
behaviours: 'flow',
'code editor': 'code',
'code workspace': 'code',
scripts: 'code',
animation: 'timeline',
sequencer: 'timeline',
'asset browser': 'assets',
'free assets': 'assets',
'file preview': 'preview',
'session chat': 'chat',
'ai assistant': 'assistant',
ai: 'assistant'
});

/** surfaces `show` never opens or presses (rule 2): named so the refusal can say what was asked */
export const DENIED = [
'sign in',
'sign-in',
'signin',
'log in',
'login',
'account',
'profile',
'consent',
'privacy',
'publish',
'export',
'connected apps',
'connect claude',
'connector',
'payment',
'billing',
'subscription',
'settings',
'roles',
'permissions',
'invite',
'approve'
];
export const SHOW_PANELS = Object.fromEntries(PANELS.map((p) => [p.id, { key: p.key, label: p.title, via: p.via, ...(p.readOnly ? { readOnly: true } : {}) }]));

/** @param {string} name @returns {string} lower-case, single-spaced, no "panel"/"window" */
export function normalName(name) {
return String(name ?? '')
.toLowerCase()
.replace(/[_-]+/g, ' ')
.replace(/\b(panel|window|tab|view)\b/g, ' ')
.replace(/\s+/g, ' ')
.trim();
}

/** the allow-listed panel a name means, or null @param {string} name */
export function panelOf(name) {
const n = normalName(name);
if (SHOW_PANELS[n]) return n;
if (ALIASES[n]) return ALIASES[n];
return null;
}

/** is this a surface rule 2 keeps closed @param {string} name */
export function deniedPanel(name) {
const n = normalName(name);
return DENIED.some((d) => n === d || n.includes(d));
}
/** surfaces `show` never opens or presses (rule 2), by their names */
export const DENIED = BLOCKED.flatMap((b) => [b.title, ...(b.aliases ?? [])].map(normalName));

/**
* Where the camera goes to frame a box, keeping the view direction (objectActions.focusObject's
Expand Down
Loading
Loading