Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(plugins): forward OS drag positions into plugin iframes

lxk955c9d00f3c1a1b
diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts b/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts
index 55a637cf0d..90f8335fd8 100644
--- a/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts
+++ b/apps/desktop/src/components/plugins/PluginWorkbenchHost.spec.ts
@@ -330,6 +330,92 @@ describe("PluginWorkbenchHost initialization", () => {
elementFromPoint.mockRestore();
});
+ it("converts physical window coordinates to iframe CSS coordinates and throttles sub-pixel moves", async () => {
+ const { frame, postMessage } = await mountHost();
+ const elementFromPoint = vi.spyOn(document, "elementFromPoint").mockReturnValue(frame);
+ const getBoundingClientRect = vi.spyOn(frame, "getBoundingClientRect").mockReturnValue({
+ left: 20,
+ top: 30,
+ right: 320,
+ bottom: 230,
+ width: 300,
+ height: 200,
+ x: 20,
+ y: 30,
+ toJSON: () => ({}),
+ });
+ const originalDpr = window.devicePixelRatio;
+ Object.defineProperty(window, "devicePixelRatio", { value: 2, configurable: true });
+
+ try {
+ // 1. Enter at physical (100, 120) -> CSS (50, 60) -> relative (30, 30)
+ document.dispatchEvent(
+ new CustomEvent("dbx:tauri-file-drop", {
+ detail: { type: "enter", position: { x: 100, y: 120 } },
+ cancelable: true,
+ }),
+ );
+ expect(postMessage).toHaveBeenLastCalledWith(expect.objectContaining({ type: "dragstate", active: true, position: { x: 30, y: 30 } }), "*");
+
+ postMessage.mockClear();
+
+ // 2. Over with sub-pixel move: physical (101, 120) -> CSS (50.5, 60) -> relative (30.5, 30) -> deltaX = 0.5 < 1px
+ document.dispatchEvent(
+ new CustomEvent("dbx:tauri-file-drop", {
+ detail: { type: "over", position: { x: 101, y: 120 } },
+ cancelable: true,
+ }),
+ );
+ expect(postMessage).not.toHaveBeenCalled();
+
+ // 3. Over with >= 1px move: physical (110, 120) -> CSS (55, 60) -> relative (35, 30) -> deltaX = 5 >= 1px
+ document.dispatchEvent(
+ new CustomEvent("dbx:tauri-file-drop", {
+ detail: { type: "over", position: { x: 110, y: 120 } },
+ cancelable: true,
+ }),
+ );
+ expect(postMessage).toHaveBeenLastCalledWith(expect.objectContaining({ type: "dragstate", active: true, position: { x: 35, y: 30 } }), "*");
+
+ postMessage.mockClear();
+
+ // 4. Drop at physical (120, 140) -> CSS (60, 70) -> relative (40, 40)
+ mocks.openDroppedPluginLocalFiles.mockResolvedValueOnce({
+ dropId: "drop-coord-test",
+ truncated: false,
+ files: [{ handleId: "h-coord", name: "b.txt", size: 5, contentType: "text/plain", write: false }],
+ });
+ document.dispatchEvent(
+ new CustomEvent("dbx:tauri-file-drop", {
+ detail: { type: "drop", paths: ["/tmp/b.txt"], position: { x: 120, y: 140 } },
+ cancelable: true,
+ }),
+ );
+
+ await vi.waitFor(() => {
+ expect(postMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: "filedrop",
+ position: { x: 40, y: 40 },
+ dropId: "drop-coord-test",
+ }),
+ "*",
+ );
+ });
+ expect(postMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: "dragstate",
+ active: false,
+ }),
+ "*",
+ );
+ } finally {
+ Object.defineProperty(window, "devicePixelRatio", { value: originalDpr, configurable: true });
+ getBoundingClientRect.mockRestore();
+ elementFromPoint.mockRestore();
+ }
+ });
+
it("serves all connections with connected status when plugin has host.connections:read", async () => {
const pluginWithPerm: InstalledPlugin = {
manifest: { id: "sample", name: "Sample", version: "1.0.0", permissions: ["host.connections:read"], drivers: [], contributions: [] },
diff --git a/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue b/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue
index da8b775f33..dcab7b5d3a 100644
--- a/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue
+++ b/apps/desktop/src/components/plugins/PluginWorkbenchHost.vue
@@ -412,10 +412,12 @@ interface TauriFileDropPayload {
}
let dropDragActive = false;
+let lastDragPoint: { x: number; y: number } | null = null;
-function forwardDragState(active: boolean): void {
+function forwardDragState(active: boolean, position?: { x: number; y: number }): void {
dropDragActive = active;
- bridge?.forwardDragState(active);
+ lastDragPoint = active && position ? { x: position.x, y: position.y } : null;
+ bridge?.forwardDragState(active, position);
}
function onHostFileDrop(event: Event): void {
@@ -432,20 +434,35 @@ function onHostFileDrop(event: Event): void {
}
// Overlay titlebar: the webview starts at the window origin, so physical
// window coordinates divide straight into CSS pixels via devicePixelRatio.
- const scale = window.devicePixelRatio || 1;
- if (document.elementFromPoint(position.x / scale, position.y / scale) !== frame) {
+ // A non-finite ratio (e.g. a NaN reading) must behave like 1 so a bad
+ // reading cannot turn every forwarded coordinate into NaN.
+ const dpr = window.devicePixelRatio;
+ const scale = Number.isFinite(dpr) && dpr > 0 ? dpr : 1;
+ const cssX = position.x / scale;
+ const cssY = position.y / scale;
+ if (document.elementFromPoint(cssX, cssY) !== frame) {
if (dropDragActive) forwardDragState(false);
return;
}
// Claim the drop so the host fallback (open as SQL/database) does not run.
event.preventDefault();
+ const rect = frame.getBoundingClientRect();
+ const point = {
+ x: cssX - rect.left,
+ y: cssY - rect.top,
+ };
if (payload.type !== "drop") {
- if (!dropDragActive) forwardDragState(true);
+ if (dropDragActive && lastDragPoint && Math.abs(lastDragPoint.x - point.x) < 1 && Math.abs(lastDragPoint.y - point.y) < 1) {
+ return;
+ }
+ forwardDragState(true, point);
return;
}
- forwardDragState(false);
const paths = (payload.paths || []).filter((path) => typeof path === "string" && path);
- if (!paths.length || !bridge) return;
+ if (!paths.length || !bridge) {
+ forwardDragState(false);
+ return;
+ }
// Pin the owner and generation before the await: the expansion runs on a
// Rust blocking thread and can land after a teardown or identity rebuild.
const pluginId = props.plugin.manifest.id;
@@ -467,10 +484,17 @@ function onHostFileDrop(event: Event): void {
});
return;
}
- if (files.length) bridge?.forwardFileDrop(files, { dropId, truncated });
- else console.error("[DBX][plugin-workbench:drop] no dropped files could be opened", paths);
+ if (files.length) {
+ bridge?.forwardFileDrop(files, { dropId, truncated, position: point });
+ } else {
+ console.error("[DBX][plugin-workbench:drop] no dropped files could be opened", paths);
+ }
} catch (error) {
console.error("[DBX][plugin-workbench:drop]", error);
+ } finally {
+ if (!disposed && generation === loadGeneration) {
+ forwardDragState(false);
+ }
}
})();
}
@@ -885,6 +909,8 @@ defineExpose({ requestClose });
onBeforeUnmount(() => {
disposed = true;
+ dropDragActive = false;
+ lastDragPoint = null;
loadGeneration += 1;
// An unanswered consent dialog must not leave the plugin's generation
// request (and its busy lock) hanging on a dead workbench.
diff --git a/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts b/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts
index 031623fff9..80631776ff 100644
--- a/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts
+++ b/apps/desktop/src/lib/plugins/pluginHostBridge.spec.ts
@@ -1838,6 +1838,13 @@ describe("plugin SDK source", () => {
setTitle: (title: string | null) => Promise<unknown>;
getTitle: () => Promise<unknown>;
};
+ fileTransfer: {
+ onDragState: (listener: (active: boolean, position?: { x: number; y: number }) => void) => () => void;
+ onDrop: (listener: (files: unknown[], drop: unknown) => void) => () => void;
+ };
+ };
+ document: {
+ dispatchEvent: ReturnType<typeof vi.fn>;
};
receiveHostMessage: (message: unknown) => void;
}
@@ -1851,6 +1858,7 @@ describe("plugin SDK source", () => {
},
dispatchEvent: vi.fn(),
} as unknown as Document;
+ sandbox.document = document as unknown as SdkWindow["document"];
let onMessage: ((event: MessageEvent) => void) | undefined;
const parent = { postMessage: (message: unknown) => posted.push(message) };
const addEventListener = (type: string, listener: (event: MessageEvent) => void) => {
@@ -2067,11 +2075,95 @@ describe("plugin SDK source", () => {
const target = { postMessage: (message: unknown) => messages.push(message) } as unknown as Window;
const bridge = new PluginHostBridge(plugin(), workbench, {}, () => target, { invoke: vi.fn(), notify: vi.fn(), sendBinary: vi.fn(), readAsset: vi.fn() });
- bridge.forwardDragState(true);
- bridge.forwardFileDrop([{ handleId: "t1", name: "a.txt", size: 1, contentType: "text/plain" }]);
+ bridge.forwardDragState(true, { x: 15, y: 25 });
+ bridge.forwardFileDrop([{ handleId: "t1", name: "a.txt", size: 1, contentType: "text/plain" }], { dropId: "d1", truncated: false, position: { x: 15, y: 25 } });
+
+ expect(messages[0]).toMatchObject({ source: "dbx-host", version: 1, type: "dragstate", active: true, position: { x: 15, y: 25 } });
+ expect(messages[1]).toMatchObject({ source: "dbx-host", version: 1, type: "filedrop", files: [{ handleId: "t1", name: "a.txt" }], position: { x: 15, y: 25 } });
+ });
+
+ it("sdk delivers drag coordinates and drop position to listeners while keeping dbx-plugin-dragstate boolean", () => {
+ const posted: unknown[] = [];
+ const sdkWindow = loadSdk(posted);
+ const { dbxPlugin } = sdkWindow;
+ expect(dbxPlugin).toBeDefined();
+
+ const dragEvents: Array<{ active: boolean; position?: { x: number; y: number } }> = [];
+ const dropEvents: Array<{ files: unknown[]; drop: unknown }> = [];
+
+ dbxPlugin!.fileTransfer.onDragState((active, position) => {
+ dragEvents.push({ active, position });
+ });
+ dbxPlugin!.fileTransfer.onDrop((files, drop) => {
+ dropEvents.push({ files, drop });
+ });
+
+ // 1. Drag enter with position
+ sdkWindow.receiveHostMessage({
+ source: "dbx-host",
+ version: 1,
+ type: "dragstate",
+ active: true,
+ position: { x: 100, y: 200 },
+ });
+ expect(dragEvents).toEqual([{ active: true, position: { x: 100, y: 200 } }]);
+ expect(sdkWindow.document.dispatchEvent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: "dbx-plugin-dragstate",
+ detail: true,
+ }),
+ );
- expect(messages[0]).toMatchObject({ source: "dbx-host", version: 1, type: "dragstate", active: true });
- expect(messages[1]).toMatchObject({ source: "dbx-host", version: 1, type: "filedrop", files: [{ handleId: "t1", name: "a.txt" }] });
+ // 2. Drag over with updated position
+ sdkWindow.receiveHostMessage({
+ source: "dbx-host",
+ version: 1,
+ type: "dragstate",
+ active: true,
+ position: { x: 150, y: 250 },
+ });
+ expect(dragEvents[1]).toEqual({ active: true, position: { x: 150, y: 250 } });
+
+ // 3. Drop with position
+ sdkWindow.receiveHostMessage({
+ source: "dbx-host",
+ version: 1,
+ type: "filedrop",
+ files: [{ handleId: "h1", name: "test.txt", size: 10 }],
+ dropId: "drop-1",
+ truncated: false,
+ position: { x: 150, y: 250 },
+ });
+ expect(dropEvents).toEqual([
+ {
+ files: [{ handleId: "h1", name: "test.txt", size: 10 }],
+ drop: { dropId: "drop-1", truncated: false, position: { x: 150, y: 250 } },
+ },
+ ]);
+ expect(sdkWindow.document.dispatchEvent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: "dbx-plugin-filedrop",
+ detail: {
+ files: [{ handleId: "h1", name: "test.txt", size: 10 }],
+ drop: { dropId: "drop-1", truncated: false, position: { x: 150, y: 250 } },
+ },
+ }),
+ );
+
+ // 4. Drag leave without position
+ sdkWindow.receiveHostMessage({
+ source: "dbx-host",
+ version: 1,
+ type: "dragstate",
+ active: false,
+ });
+ expect(dragEvents[2]).toEqual({ active: false, position: undefined });
+ expect(sdkWindow.document.dispatchEvent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ type: "dbx-plugin-dragstate",
+ detail: false,
+ }),
+ );
});
it("sdk exposes the fileTransfer namespace and drop listeners", () => {
diff --git a/apps/desktop/src/lib/plugins/pluginHostBridge.ts b/apps/desktop/src/lib/plugins/pluginHostBridge.ts
index 5ec566b597..20e5cb40d7 100644
--- a/apps/desktop/src/lib/plugins/pluginHostBridge.ts
+++ b/apps/desktop/src/lib/plugins/pluginHostBridge.ts
@@ -128,6 +128,11 @@ export interface PluginFileHandleMeta {
relativePath?: string;
}
+export interface PluginDragPosition {
+ x: number;
+ y: number;
+}
+
export interface PluginPickFilesOptions {
multiple?: boolean;
}
@@ -607,13 +612,27 @@ export class PluginHostBridge {
}
/** Tell the plugin whether an OS-level file drag is currently over its workbench. */
- forwardDragState(active: boolean): void {
- this.post({ source: HOST_MESSAGE_SOURCE, version: BRIDGE_VERSION, type: "dragstate", active });
+ forwardDragState(active: boolean, position?: PluginDragPosition): void {
+ this.post({
+ source: HOST_MESSAGE_SOURCE,
+ version: BRIDGE_VERSION,
+ type: "dragstate",
+ active,
+ position: position ? { x: position.x, y: position.y } : undefined,
+ });
}
/** Hand the plugin already-opened handles for files dropped onto its workbench. */
- forwardFileDrop(files: PluginFileHandleMeta[], drop?: { dropId?: string; truncated?: boolean }): void {
- this.post({ source: HOST_MESSAGE_SOURCE, version: BRIDGE_VERSION, type: "filedrop", files, dropId: drop?.dropId, truncated: drop?.truncated === true });
+ forwardFileDrop(files: PluginFileHandleMeta[], drop?: { dropId?: string; truncated?: boolean; position?: PluginDragPosition }): void {
+ this.post({
+ source: HOST_MESSAGE_SOURCE,
+ version: BRIDGE_VERSION,
+ type: "filedrop",
+ files,
+ dropId: drop?.dropId,
+ truncated: drop?.truncated === true,
+ position: drop?.position ? { x: drop.position.x, y: drop.position.y } : undefined,
+ });
}
private async handleRequest(request: PluginRequestMessage, target: Window): Promise<void> {
@@ -1599,14 +1618,24 @@ export function pluginSdkSource(initialTheme?: PluginBridgeTheme): string {
document.dispatchEvent(new CustomEvent('dbx-plugin-binary', { detail: payload }));
} else if (message.type === 'filedrop') {
const files = Array.isArray(message.files) ? message.files : [];
+ const position = (message.position && typeof message.position.x === 'number' && typeof message.position.y === 'number')
+ ? { x: message.position.x, y: message.position.y }
+ : undefined;
// The drop metadata rides as a second listener argument so existing
// single-parameter listeners keep working unchanged.
- const drop = { dropId: typeof message.dropId === 'string' ? message.dropId : undefined, truncated: message.truncated === true };
+ const drop = {
+ dropId: typeof message.dropId === 'string' ? message.dropId : undefined,
+ truncated: message.truncated === true,
+ position,
+ };
listeners.filedrop.forEach((listener) => listener(files, drop));
document.dispatchEvent(new CustomEvent('dbx-plugin-filedrop', { detail: { files, drop } }));
} else if (message.type === 'dragstate') {
const active = message.active === true;
- listeners.dragstate.forEach((listener) => listener(active));
+ const position = (message.position && typeof message.position.x === 'number' && typeof message.position.y === 'number')
+ ? { x: message.position.x, y: message.position.y }
+ : undefined;
+ listeners.dragstate.forEach((listener) => listener(active, position));
document.dispatchEvent(new CustomEvent('dbx-plugin-dragstate', { detail: active }));
} else if (message.type === 'workbench/close') {
const notifyClose = (listener) => Promise.resolve().then(listener).catch(() => undefined);
diff --git a/docs/content/docs/plugin-development.cn.mdx b/docs/content/docs/plugin-development.cn.mdx
index e9d8e75c27..0074b23bb2 100644
--- a/docs/content/docs/plugin-development.cn.mdx
+++ b/docs/content/docs/plugin-development.cn.mdx
@@ -633,8 +633,8 @@ const offDrag = fileTransfer.onDragState((active) => showDropOverlay(active));
| `beginSave({ name, contentType?, size? })` | 原生保存对话框 + 写句柄;返回 `{ handleId, chunkBytes }`,用户取消时为 `null`。 |
| `write(handleId, offset, data)` | 写入一个分块(二进制 transfer 或 base64);返回 `{ written, nextOffset }`。 |
| `finish(handleId)` / `cancel(handleId)` | 冲洗并关闭写句柄 / 丢弃任意句柄。 |
-| `onDrop(fn)` | 拖入本工作台的文件以读句柄送达;拖入文件夹会被展开为其中包含的文件(`.git` 等点开头文件与目录会被跳过),每个文件额外携带 `relativePath`(以 `/` 分隔、以拖入文件夹自身名字开头的路径,如 `folder/nested/a.csv`),可用于还原拖入的目录结构,也能区分不同拖入根目录下的同名文件。监听器签名为 `(files, { dropId, truncated })`:`dropId` 标识本次拖入的整组条目(取消与进度记账的分组键),`truncated` 为 `true` 表示展开因 2000 文件或 8 层深度上限被截断。 |
-| `onDragState(fn)` | 是否有系统拖拽悬在本工作台上方;用它驱动拖放遮罩。 |
+| `onDrop(fn)` | 拖入本工作台的文件以读句柄送达;拖入文件夹会被展开为其中包含的文件(`.git` 等点开头文件与目录会被跳过),每个文件额外携带 `relativePath`(以 `/` 分隔、以拖入文件夹自身名字开头的路径,如 `folder/nested/a.csv`),可用于还原拖入的目录结构,也能区分不同拖入根目录下的同名文件。监听器签名为 `(files, { dropId, truncated, position })`:`dropId` 标识本次拖入的整组条目(取消与进度记账的分组键),`truncated` 为 `true` 表示展开因 2000 文件或 8 层深度上限被截断,`position` 为 drop 落点相对于 iframe 视口内的 CSS 坐标 `{ x, y }`。 |
+| `onDragState(fn)` | 是否有系统拖拽悬在本工作台上方;用它驱动拖放遮罩或高亮悬停元素。监听器签名为 `(active, position)`:`active` 为布尔值,`position` 为光标当前相对于 iframe 视口内的 CSS 坐标 `{ x, y }`(拖拽移出或结束时为 `undefined`)。 |
桌面端与网页端的行为差异:请以 init 消息里 additive 的 `capabilities.fileTransfer` 标志位(`pick`、`beginSave`、`read`、`drop`、`folderExpansion`)做能力探测,不要靠试调用。桌面端 `pick` / `beginSave` 走原生对话框、`onDrop` 接收系统拖放(句柄由宿主惰性打开,读时分块流式,因此超大文件夹与大文件都不会占满句柄;选取文件数超过共享句柄池时自动降级为惰性条目,不会静默丢弃)。网页端 `pick` 回退到浏览器文件选择器、`beginSave` 回退为内存缓冲加浏览器下载、`onDrop` / `onDragState` 不会触发(`drop`/`folderExpansion` 为 `false`)、句柄也没有 `relativePath`。`onDrop` 只在拖放落点位于本插件工作台区域内时触发;落点在宿主其他区域时保持宿主自身的行为。
diff --git a/docs/content/docs/plugin-development.mdx b/docs/content/docs/plugin-development.mdx
index 0b11c20f2b..479fe71496 100644
--- a/docs/content/docs/plugin-development.mdx
+++ b/docs/content/docs/plugin-development.mdx
@@ -636,8 +636,8 @@ const offDrag = fileTransfer.onDragState((active) => showDropOverlay(active));
| `beginSave({ name, contentType?, size? })` | Native save dialog + write handle; resolves `{ handleId, chunkBytes }`, or `null` when the user cancels. |
| `write(handleId, offset, data)` | Writes one chunk (transferred binary or base64); resolves `{ written, nextOffset }`. |
| `finish(handleId)` / `cancel(handleId)` | Flush-closes a write handle / discards any handle. |
-| `onDrop(fn)` | Files dropped onto this workbench arrive as read handles. A dropped folder is expanded into the regular files it contains (dotfiles and dot-directories like `.git` are skipped); each expanded file carries `relativePath` — its '/'-separated path starting with the dropped folder's own name (`folder/nested/a.csv`) — so the plugin can rebuild the dragged structure and tell same-named files under different dropped roots apart. Listeners receive `(files, { dropId, truncated })`: `dropId` groups this drop's entries (cancellation and progress bookkeeping), `truncated` is `true` when the 2000-file or 8-depth expansion cap cut the delivery short. |
-| `onDragState(fn)` | Whether an OS drag is currently over this workbench; drive drop overlays with it. |
+| `onDrop(fn)` | Files dropped onto this workbench arrive as read handles. A dropped folder is expanded into the regular files it contains (dotfiles and dot-directories like `.git` are skipped); each expanded file carries `relativePath` — its '/'-separated path starting with the dropped folder's own name (`folder/nested/a.csv`) — so the plugin can rebuild the dragged structure and tell same-named files under different dropped roots apart. Listeners receive `(files, { dropId, truncated, position })`: `dropId` groups this drop's entries (cancellation and progress bookkeeping), `truncated` is `true` when the 2000-file or 8-depth expansion cap cut the delivery short, and `position` provides the CSS coordinates `{ x, y }` relative to the iframe viewport. |
+| `onDragState(fn)` | Whether an OS drag is currently over this workbench; drive drop overlays or element hover targets with it. The listener signature is `(active, position)`: `active` is boolean, and `position` provides the CSS coordinates `{ x, y }` relative to the iframe viewport (or `undefined` when leaving or ending). |
Desktop and web hosts differ in what the namespace can do — gate on the additive `capabilities.fileTransfer` flags (`pick`, `beginSave`, `read`, `drop`, `folderExpansion`) instead of probing calls. On desktop, `pick` / `beginSave` use native dialogs and `onDrop` receives OS drops; dropped entries are opened lazily and streamed in chunks, so very large folders and multi-gigabyte files never exhaust handles or memory, and picking more files than the shared handle registry holds downgrades them to lazily-opened entries instead of dropping any. On the web host, `pick` falls back to a browser file input, `beginSave` buffers in memory and downloads through the browser, `onDrop` / `onDragState` never fire (`drop`/`folderExpansion` are `false` there), and handles carry no `relativePath`. `onDrop` only fires for drops that land inside this plugin's workbench area; drops elsewhere keep the host's own behavior.