diff --git a/.agents/skills/verify-deepseekbot/features/team-mode.md b/.agents/skills/verify-deepseekbot/features/team-mode.md
index f8bb887685..2cf26a5a75 100644
--- a/.agents/skills/verify-deepseekbot/features/team-mode.md
+++ b/.agents/skills/verify-deepseekbot/features/team-mode.md
@@ -91,7 +91,7 @@ For a Bot owned by an ordinary Team member, send a real DM with `send --as` and
C5 checks subscription selection with an explicit account grant and after revocation. It also checks that a second account stays unavailable and a member cannot change another member's Bot. Run it with `--scenario C5 --no-subscriptions`. In the Web Client, open Bot Settings, Team, then edit a role. Select a named account in Available models, save, and confirm the role name appears on the account row in Model providers.
-C6 checks the phone’s Host Session authority through the CLI. Run the suite with `--scenario C6` on a fresh isolated Host. Confirm the Owner can list, read and continue a DSH-native Session, and a member sees their Bot’s Session while native read, follow, send and Model Choice are refused. On the assigned phone, open Settings → Interface, enable Show Sessions tab, and open the native row. Send a unique follow-up and confirm the reply appears in the same Session. Turn the switch off and confirm the tab disappears.
+C6 checks the phone’s Host Session authority through the CLI. Run the suite with `--scenario C6` on a fresh isolated Host. Confirm the Owner can list, read and continue a DSH-native Session, and a member sees their Bot’s Session while native read, follow, send and Model Choice are refused. On the assigned phone, open Settings → Interface, enable Show Sessions tab, and open the native row. Send a unique follow-up and confirm the reply appears in the same Session. Search for a Session title and a Human message, then search for a marker found only in its model reply. Use Filter and sort to change the source while a query is active, and relaunch the app to check that the sort survives. The C6 CLI gate also checks that a member can find their Bot’s prompt and gets no matches for native Sessions and another Bot. Turn the switch off and confirm the tab disappears.
B2 checks fixed synthetic paths, the secret environment count and the local test Host socket. Verify that the Shell trace and the own-file marker establish the positive control. Retry `inconclusive` results on an isolated Host. They exit nonzero and leave the M15 gate unsatisfied.
diff --git a/apps/mobile/DESIGN.md b/apps/mobile/DESIGN.md
index c47573bc46..da1f132960 100644
--- a/apps/mobile/DESIGN.md
+++ b/apps/mobile/DESIGN.md
@@ -147,6 +147,10 @@ The current inserted alert occupies layout space above navigation. It owns its t
References: [Apple toolbars](https://developer.apple.com/design/human-interface-guidelines/toolbars), [Apple sheets](https://developer.apple.com/design/human-interface-guidelines/sheets), [Material bottom sheets](https://m3.material.io/components/bottom-sheets/guidelines), [Android radio selection](https://developer.android.com/develop/ui/compose/components/radio-button).
+## Phone Sessions query controls
+
+The Sessions tab adds Search and Filter and sort to its navigation bar. Search uses the existing iOS header search and Android Compose Material 3 `DockedSearchBar`, with the virtualized list below it. End editing to return to the toolbar and keep the query. Close search to clear the query. The iOS navigation bar’s pull-down `UIMenu` shows inline checkmark groups for Sort by and Source. The Android `ModalBottomSheet` shows the same choices with radio buttons. Select an option to apply it immediately. Sessions sort by last Human turn by default, with creation time and last activity also available. The device remembers the sort. Source is All, Native (Host Owner) or a Bot with visible Sessions. Search and source can apply together.
+
## Android chat top bar and composer
Android conversations use the floating island header specified above, replacing the previous continuous `TopAppBar` by explicit Human request (#3621). The identity island displays the existing Bot/channel avatar, name and live status or member count; it opens the same Profile as the trailing action. Calling stays conditional on the existing capability check, and group channels never receive a Call action. A native progress indicator and connection label retain reconnection feedback. The name is always one line with trailing ellipsis, with one smaller secondary status line. Native text scaling remains enabled; all three islands share a common height sufficient for these two text lines, and the single-action buttons stay circular at that same height. The measured header height reserves the list's initial top space, including system insets, while scrolling messages pass underneath the transparent overlay and its fade.
diff --git a/apps/mobile/src/features/sessions/strings.ts b/apps/mobile/src/features/sessions/strings.ts
index 0d29ef39cb..1f42ab486e 100644
--- a/apps/mobile/src/features/sessions/strings.ts
+++ b/apps/mobile/src/features/sessions/strings.ts
@@ -7,6 +7,18 @@ export const en = {
native: 'Native session',
untitled: 'Untitled session',
empty: 'No sessions on this Host.',
+ noMatches: 'No matching sessions.',
+ search: 'Search sessions',
+ options: 'Filter and sort',
+ sortLabel: 'Sort by',
+ sourceLabel: 'Source',
+ all: 'All',
+ nativeSource: 'Native',
+ sort: {
+ 'last-human-turn': 'Last human turn',
+ created: 'Creation time',
+ 'last-activity': 'Last activity',
+ },
offline: 'Connect to a Host to see its sessions.',
loadFailed: 'Couldn’t load sessions.',
running: 'Running',
@@ -166,6 +178,18 @@ export const zh: typeof en = {
native: '原生会话',
untitled: '未命名会话',
empty: '此 Host 还没有会话。',
+ noMatches: '没有匹配的会话。',
+ search: '搜索会话',
+ options: '筛选与排序',
+ sortLabel: '排序方式',
+ sourceLabel: '来源',
+ all: '全部',
+ nativeSource: '原生',
+ sort: {
+ 'last-human-turn': '最近的 Human 消息',
+ created: '创建时间',
+ 'last-activity': '最近活动',
+ },
offline: '连接 Host 后可查看会话。',
loadFailed: '加载会话失败。',
running: '运行中',
diff --git a/apps/mobile/src/ui/interface-preferences.ts b/apps/mobile/src/ui/interface-preferences.ts
index c604a34d6b..c9093aab13 100644
--- a/apps/mobile/src/ui/interface-preferences.ts
+++ b/apps/mobile/src/ui/interface-preferences.ts
@@ -1,4 +1,5 @@
import { useSyncExternalStore } from 'react';
+import { isHostSessionSort, type HostSessionSort } from '@botharness/host-protocol/host-sessions';
export type LanguagePreference = 'system' | 'en' | 'zh';
export type AppearancePreference = 'system' | 'light' | 'dark';
@@ -7,6 +8,7 @@ export type InterfacePreferences = {
language: LanguagePreference;
appearance: AppearancePreference;
sessionsTab: boolean;
+ sessionSort: HostSessionSort;
inAppAlerts: boolean;
inAppAlertStyle: InAppAlertStyle;
};
@@ -29,6 +31,7 @@ export function createInterfacePreferences() {
language: 'system',
appearance: 'system',
sessionsTab: false,
+ sessionSort: 'last-human-turn',
inAppAlerts: true,
inAppAlertStyle: 'overlay',
};
@@ -67,6 +70,8 @@ export function createInterfacePreferences() {
if (!touched && typeof saved === 'object' && saved !== null) {
if ('sessionsTab' in saved && typeof saved.sessionsTab === 'boolean')
value.sessionsTab = saved.sessionsTab;
+ if ('sessionSort' in saved && isHostSessionSort(saved.sessionSort))
+ value.sessionSort = saved.sessionSort;
if ('inAppAlerts' in saved && typeof saved.inAppAlerts === 'boolean')
value.inAppAlerts = saved.inAppAlerts;
if (
@@ -112,6 +117,12 @@ export function createInterfacePreferences() {
if (snapshot.loaded) persist();
publish();
},
+ setSessionSort(sessionSort: HostSessionSort) {
+ touched = true;
+ value = { ...value, sessionSort };
+ if (snapshot.loaded) persist();
+ publish();
+ },
setInAppAlerts(inAppAlerts: boolean) {
touched = true;
value = { ...value, inAppAlerts };
@@ -140,6 +151,15 @@ export function createInterfacePreferences() {
export const interfacePreferences = createInterfacePreferences();
const sessionsTabSnapshot = () => interfacePreferences.getSnapshot().sessionsTab;
+const sessionSortSnapshot = () => interfacePreferences.getSnapshot().sessionSort;
+
+export function useSessionSort() {
+ return useSyncExternalStore(
+ interfacePreferences.subscribe,
+ sessionSortSnapshot,
+ sessionSortSnapshot,
+ );
+}
export function useSessionsTab() {
return useSyncExternalStore(
diff --git a/apps/mobile/src/ui/shell/host-session-options.tsx b/apps/mobile/src/ui/shell/host-session-options.tsx
new file mode 100644
index 0000000000..eb1ab5f322
--- /dev/null
+++ b/apps/mobile/src/ui/shell/host-session-options.tsx
@@ -0,0 +1,109 @@
+import { FlatList, Pressable } from 'react-native';
+import { Sheet } from '../chat/sheet';
+import { segmentCorners } from '../design/segment-corners';
+import { useDesignTheme } from '../design/theme';
+import { androidSettings, space } from '../design/tokens';
+import { RadioMark } from '../primitives/radio-mark';
+import { Text } from '../primitives/text';
+import { useStrings } from '../strings';
+import { HeaderAction } from './header-action';
+
+type Choice = { id: string; label: string; select(): void };
+export type SessionOptionGroup = {
+ id: string;
+ label: string;
+ selected: string;
+ choices: Choice[];
+};
+
+export function HostSessionOptionsButton({ active, onOpen }: { active: boolean; onOpen(): void }) {
+ const t = useStrings().hostSessions;
+ return (
+
+ );
+}
+
+type HostSessionOptionsSheetProps = {
+ open: boolean;
+ groups: readonly SessionOptionGroup[];
+ onClose(): void;
+};
+
+type Row =
+ | { kind: 'heading'; key: string; label: string }
+ | {
+ kind: 'choice';
+ key: string;
+ choice: Choice;
+ selected: boolean;
+ first: boolean;
+ last: boolean;
+ };
+
+export function HostSessionOptionsSheet({ open, groups, onClose }: HostSessionOptionsSheetProps) {
+ const t = useStrings().hostSessions;
+ const theme = useDesignTheme();
+ if (!open) return null;
+ const rows = groups.flatMap((group): Row[] => [
+ { kind: 'heading', key: group.id, label: group.label },
+ ...group.choices.map((choice, index): Row => ({
+ kind: 'choice',
+ key: `${group.id}:${choice.id}`,
+ choice,
+ selected: group.selected === choice.id,
+ first: index === 0,
+ last: index === group.choices.length - 1,
+ })),
+ ]);
+ return (
+
+ row.key}
+ contentContainerStyle={{ paddingHorizontal: space.x5, paddingBottom: space.x5 }}
+ renderItem={({ item }) => {
+ if (item.kind === 'heading')
+ return (
+
+ {item.label}
+
+ );
+ return (
+ ({
+ minHeight: theme.touch,
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: space.x4,
+ paddingHorizontal: space.x5,
+ paddingVertical: space.x3,
+ ...segmentCorners(item.first, item.last),
+ marginTop: item.first ? 0 : androidSettings.segmentGap,
+ backgroundColor: pressed ? theme.layer.raised.pressed : theme.layer.raised.fill,
+ })}
+ >
+
+ {item.choice.label}
+
+ );
+ }}
+ />
+
+ );
+}
diff --git a/apps/mobile/src/ui/shell/host-sessions-screen.tsx b/apps/mobile/src/ui/shell/host-sessions-screen.tsx
index a38b2cd099..2b0ad71ccb 100644
--- a/apps/mobile/src/ui/shell/host-sessions-screen.tsx
+++ b/apps/mobile/src/ui/shell/host-sessions-screen.tsx
@@ -1,20 +1,35 @@
import { Redirect, Stack, useFocusEffect, useRouter } from 'expo-router';
import { useCallback, useRef, useState, useSyncExternalStore } from 'react';
-import { FlatList, Pressable, View } from 'react-native';
+import { FlatList, Keyboard, Platform, Pressable, View } from 'react-native';
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
import type { HostClient } from '@botharness/host-client/client';
-import { listHostSessions } from '@botharness/host-client/host-sessions';
-import type { HostSessionRow } from '@botharness/host-protocol/host-sessions';
+import { readHostSessionList } from '@botharness/host-client/host-sessions';
+import {
+ HOST_SESSION_SEARCH_MAX,
+ HOST_SESSION_SORTS,
+ type HostSessionFilter,
+ type HostSessionRow,
+ type HostSessionSourceOption,
+} from '@botharness/host-protocol/host-sessions';
import { useHostSession } from '../../host/host-session';
import { sessionReadHost } from '../../host/session-detail';
import { BotPortrait } from '../bot-avatar';
import { SheetLoading } from '../chat/sheet';
import { pressTint, useDesignTheme } from '../design/theme';
-import { radius, space } from '../design/tokens';
-import { useSessionsTab } from '../interface-preferences';
+import { materialSearchHeight } from '../design/material-search';
+import { radius, space, tabHeader } from '../design/tokens';
+import { interfacePreferences, useSessionsTab, useSessionSort } from '../interface-preferences';
import { ReadFailure } from '../primitives/read-failure';
import { Text } from '../primitives/text';
import { useStrings } from '../strings';
import { useFloatingTabInset } from './floating-tab-inset';
+import { HeaderAction } from './header-action';
+import { HeaderSearch } from './header-search';
+import {
+ HostSessionOptionsButton,
+ HostSessionOptionsSheet,
+ type SessionOptionGroup,
+} from './host-session-options';
import { AssignmentSessionIcon, ChevronRightIcon } from './icons';
export function HostSessionsScreen() {
@@ -22,20 +37,20 @@ export function HostSessionsScreen() {
const { client, saved } = useHostSession();
const t = useStrings().hostSessions;
if (!enabled) return ;
+ if (client && saved)
+ return (
+
+ );
return (
<>
- {client && saved ? (
-
- ) : (
-
- {t.offline}
-
- )}
+
+ {t.offline}
+
>
);
}
@@ -43,8 +58,26 @@ export function HostSessionsScreen() {
function HostSessionsList({ client, hostId }: { client: HostClient; hostId: string }) {
const router = useRouter();
const t = useStrings().hostSessions;
+ const theme = useDesignTheme();
+ const insets = useSafeAreaInsets();
const bottom = useFloatingTabInset();
- const [rows, setRows] = useState();
+ const sort = useSessionSort();
+ const [source, setSource] = useState('all');
+ const [sources, setSources] = useState();
+ const [draft, setDraft] = useState('');
+ const [debounced, setDebounced] = useState('');
+ const debounceTimer = useRef>(undefined);
+ const pendingSearch = useRef('');
+ const [searchOpen, setSearchOpen] = useState(false);
+ const [optionsOpen, setOptionsOpen] = useState(false);
+ const [result, setResult] = useState<{
+ search: string;
+ source: HostSessionFilter;
+ rows: HostSessionRow[];
+ }>();
+ const search = draft.trim();
+ const searchReady = search === '' || search === debounced;
+ const rows = result?.search === search && result.source === source ? result.rows : undefined;
const [failed, setFailed] = useState(false);
const [busy, setBusy] = useState(false);
const flight = useRef(undefined);
@@ -53,16 +86,33 @@ function HostSessionsList({ client, hostId }: { client: HostClient; hostId: stri
() => client.getSnapshot().connection.status === 'connected',
);
+ const changeSearch = (text: string, immediate = false) => {
+ setDraft(text);
+ clearTimeout(debounceTimer.current);
+ const query = text.trim();
+ pendingSearch.current = query;
+ if (query === '' || immediate) setDebounced(query);
+ else debounceTimer.current = setTimeout(() => setDebounced(query), 250);
+ };
+ useFocusEffect(
+ useCallback(() => {
+ setDebounced(pendingSearch.current);
+ return () => clearTimeout(debounceTimer.current);
+ }, []),
+ );
+
const refresh = useCallback(() => {
- if (!online || flight.current !== undefined) return;
+ if (!online || !searchReady || flight.current !== undefined) return;
const abort = new AbortController();
flight.current = abort;
setFailed(false);
setBusy(true);
- void listHostSessions(sessionReadHost(client, abort.signal))
+ void readHostSessionList(sessionReadHost(client, abort.signal), { search, sort, source })
.then(
(value) => {
- if (!abort.signal.aborted) setRows(value);
+ if (abort.signal.aborted) return;
+ setResult({ search, source, rows: value.sessions });
+ setSources(value.sources);
},
() => {
if (!abort.signal.aborted) setFailed(true);
@@ -73,7 +123,7 @@ function HostSessionsList({ client, hostId }: { client: HostClient; hostId: stri
flight.current = undefined;
setBusy(false);
});
- }, [client, online]);
+ }, [client, online, search, searchReady, sort, source]);
useFocusEffect(
useCallback(() => {
refresh();
@@ -85,6 +135,44 @@ function HostSessionsList({ client, hostId }: { client: HostClient; hostId: stri
}, [refresh]),
);
+ const groups: SessionOptionGroup[] = [
+ {
+ id: 'sort',
+ label: t.sortLabel,
+ selected: sort,
+ choices: HOST_SESSION_SORTS.map((id) => ({
+ id,
+ label: t.sort[id],
+ select: () => interfacePreferences.setSessionSort(id),
+ })),
+ },
+ {
+ id: 'source',
+ label: t.sourceLabel,
+ selected: source,
+ choices: [
+ { id: 'all', label: t.all, select: () => setSource('all') },
+ ...(sources ?? [])
+ .slice()
+ .sort((a, b) => {
+ if (a.kind === 'native') return b.kind === 'native' ? 0 : -1;
+ if (b.kind === 'native') return 1;
+ return a.displayName.localeCompare(b.displayName) || a.botSlug.localeCompare(b.botSlug);
+ })
+ .map((item) => {
+ const id: HostSessionFilter = item.kind === 'native' ? 'native' : `bot:${item.botSlug}`;
+ return {
+ id,
+ label: item.kind === 'native' ? t.nativeSource : item.displayName,
+ select: () => setSource(id),
+ };
+ }),
+ ],
+ },
+ ];
+ const canQuery = online && sources !== undefined;
+ const optionsActive = sort !== 'last-human-turn' || source !== 'all';
+
const open = (row: HostSessionRow) => {
router.push({
pathname: '/session/[id]',
@@ -97,38 +185,143 @@ function HostSessionsList({ client, hostId }: { client: HostClient; hostId: stri
});
};
return (
- row.sessionId}
- refreshing={online && busy && rows !== undefined}
- onRefresh={online ? refresh : undefined}
- ListHeaderComponent={
- failed && rows !== undefined ? (
-
- ) : undefined
- }
- ListEmptyComponent={
- !online ? (
-
- {t.offline}
-
- ) : failed ? (
-
- ) : rows === undefined ? (
-
- ) : (
-
- {t.empty}
-
- )
- }
- renderItem={({ item }) => (
- open(item)} />
- )}
- />
+ <>
+
+ canQuery
+ ? [
+ {
+ type: 'button',
+ label: t.search,
+ identifier: 'host-sessions-search',
+ icon: { type: 'sfSymbol', name: 'magnifyingglass' },
+ ...(search === '' ? {} : { tintColor: theme.color.accent }),
+ onPress: () => setSearchOpen(true),
+ },
+ {
+ type: 'menu',
+ label: t.options,
+ identifier: 'host-sessions-options',
+ icon: { type: 'sfSymbol', name: 'line.3.horizontal.decrease' },
+ ...(optionsActive ? { tintColor: theme.color.accent } : {}),
+ menu: {
+ multiselectable: true,
+ items: groups.map((group) => ({
+ type: 'submenu',
+ label: group.label,
+ inline: true,
+ items: group.choices.map((choice) => ({
+ type: 'action',
+ label: choice.label,
+ state: group.selected === choice.id ? 'on' : 'off',
+ onPress: choice.select,
+ })),
+ })),
+ },
+ },
+ ]
+ : [],
+ }
+ : {
+ headerRight: () =>
+ canQuery ? (
+
+ setOptionsOpen(true)}
+ />
+ setSearchOpen(true)}
+ />
+
+ ) : null,
+ }),
+ }}
+ />
+ {searchOpen ? (
+
+
+ {
+ if (!focused && Platform.OS === 'ios') setSearchOpen(false);
+ }}
+ onSubmitEditing={(text) => {
+ changeSearch(text, true);
+ Keyboard.dismiss();
+ setSearchOpen(false);
+ }}
+ onClose={() => setSearchOpen(false)}
+ />
+
+
+ ) : null}
+ row.sessionId}
+ refreshing={online && busy && rows !== undefined}
+ onRefresh={online ? refresh : undefined}
+ ListHeaderComponent={
+ failed && rows !== undefined ? (
+
+ ) : undefined
+ }
+ ListEmptyComponent={
+ !online ? (
+
+ {t.offline}
+
+ ) : failed && searchReady ? (
+
+ ) : rows === undefined ? (
+
+ ) : (
+
+ {search || source !== 'all' ? t.noMatches : t.empty}
+
+ )
+ }
+ renderItem={({ item }) => (
+ open(item)} />
+ )}
+ />
+ setOptionsOpen(false)}
+ />
+ >
);
}
diff --git a/apps/mobile/test/interface-preferences.test.ts b/apps/mobile/test/interface-preferences.test.ts
index ae7a385661..dcc98ae6eb 100644
--- a/apps/mobile/test/interface-preferences.test.ts
+++ b/apps/mobile/test/interface-preferences.test.ts
@@ -2,6 +2,24 @@ import { describe, expect, it, vi } from 'vitest';
import { createInterfacePreferences, preferredLanguage } from '../src/ui/interface-preferences';
describe('phone interface preferences', () => {
+ it('remembers Session sort across device preference restores', async () => {
+ let stored: unknown = { sessionsTab: true };
+ const storage = {
+ read: async () => stored,
+ write: (value: unknown) => {
+ stored = value;
+ },
+ };
+ const preferences = createInterfacePreferences();
+ await preferences.restore(storage);
+ expect(preferences.getSnapshot().sessionSort).toBe('last-human-turn');
+ preferences.setSessionSort('created');
+ const restarted = createInterfacePreferences();
+ await restarted.restore(storage);
+ expect(restarted.getSnapshot().sessionSort).toBe('created');
+ expect(restarted.getSnapshot().sessionsTab).toBe(true);
+ });
+
it('defaults to system and chooses the first supported preferred language', () => {
const preferences = createInterfacePreferences();
expect(preferences.getSnapshot()).toMatchObject({ language: 'system', appearance: 'system' });
@@ -82,6 +100,7 @@ describe('phone interface preferences', () => {
inAppAlerts: true,
inAppAlertStyle: 'overlay',
sessionsTab: false,
+ sessionSort: 'last-human-turn',
});
});
@@ -146,6 +165,7 @@ describe('phone interface preferences', () => {
inAppAlerts: true,
inAppAlertStyle: 'overlay',
sessionsTab: false,
+ sessionSort: 'last-human-turn',
});
});
diff --git a/apps/mobile/test/interface-settings.test.tsx b/apps/mobile/test/interface-settings.test.tsx
index a656209c90..984845e11a 100644
--- a/apps/mobile/test/interface-settings.test.tsx
+++ b/apps/mobile/test/interface-settings.test.tsx
@@ -94,6 +94,7 @@ it('updates mounted settings and theme immediately and preserves unrelated state
language: 'zh',
appearance: 'dark',
sessionsTab: false,
+ sessionSort: 'last-human-turn',
inAppAlerts: true,
inAppAlertStyle: 'overlay',
});
diff --git a/changes/phone-session-search.md b/changes/phone-session-search.md
new file mode 100644
index 0000000000..92cbed3d49
--- /dev/null
+++ b/changes/phone-session-search.md
@@ -0,0 +1,11 @@
+---
+section: Added
+---
+
+## en
+
+- Search phone Sessions by title or Human message, filter by source, and choose a sort order saved on this device. The same options are available in `deepseekbot session-list` ([#4933](https://github.com/BotHarness/DeepSeekBot/issues/4933)).
+
+## zh
+
+- 手机「会话」支持按标题或 Human 消息搜索、按来源筛选,并在本机记住排序方式。`deepseekbot session-list` 也支持这些选项([#4933](https://github.com/BotHarness/DeepSeekBot/issues/4933))。
diff --git a/docs/bot-cli.md b/docs/bot-cli.md
index 8ca369623a..3a91247465 100644
--- a/docs/bot-cli.md
+++ b/docs/bot-cli.md
@@ -662,14 +662,14 @@ Card-created rules also appear under **Always allow · this Bot** in Bot permiss
#### Host Sessions
```bash
-deepseekbot session-list
+deepseekbot session-list [--search ] [--sort last-human-turn|created|last-activity] [--source all|native|bot:]
deepseekbot session-transcript --session
deepseekbot session-live --session [--after ]
deepseekbot session-send [--]
deepseekbot session-model --session [--set | --clear]
```
-These commands use an authenticated live Host. `session-list` returns root Sessions in last Human prompt order. Rows carry the source, title when available, folder name, running state, `lastPromptAt` and `updatedAt`. The Host Owner can see native Sessions. Team members receive the Sessions of their Bots subject to the existing Session privacy checks. Native transcript, live output, prompts and Model Choice require the Host Owner. A native send returns a `requestId` after DSH admits the prompt. For Bot Sessions, keep the Bot ID argument. For native Model Choice, pass a direct API model and use `--clear` to restore the Session’s original model.
+These commands use an authenticated live Host. `session-list` returns root Sessions in descending last Human turn order by default. Use `--sort created` for newest Sessions first or `--sort last-activity` for most recent Session activity first. `--search` matches text in Session titles and Human-authored messages. Combine it with `--source native` or `--source bot:` to narrow the results. The default source is `all`. Rows carry the source, title when available, folder name, running state, `lastPromptAt` and `updatedAt`. The Host Owner can see native Sessions. Team members receive the Sessions of their Bots subject to the existing Session privacy checks. Native transcript, live output, prompts and Model Choice require the Host Owner. A native send returns a `requestId` after DSH admits the prompt. For Bot Sessions, keep the Bot ID argument. For native Model Choice, pass a direct API model and use `--clear` to restore the Session’s original model.
`session-send ` sends the Human's text straight into the Bot's current Orchestrator Session, as the input box in that Session's detail does. It is a deliberate steer and is rare. No Channel shows the text: the Session receives it raw under one line saying the Human wrote it in Session detail, and the Bot Inbox keeps it as a Human Source Event on the Human's DM, so it survives a restart or compaction. A running turn takes it at its next step, whatever the `human-dm` delivery setting; while the Bot is preparing or reconciling its Memory it waits for the next turn instead, and an idle Orchestrator wakes for it. The Bot does not have to reply; a `bot_send_message` with that `source_event_id` lands in the Human's DM without a quote. Put `--` before text that starts with `-`; text that looks like a secret flag, such as `--token` or `--api-key=…`, is still refused with `secret-in-argv`, because secrets never travel in arguments. It returns `{ sourceEventId }`. Any other Session of a Bot that can take the message is refused with `invalid-input`; a Bot that cannot take messages now, for example a paused one, is refused with `unavailable`.
diff --git a/docs/bot-cli.zh.md b/docs/bot-cli.zh.md
index 335e7edf5a..3987fca1e0 100644
--- a/docs/bot-cli.zh.md
+++ b/docs/bot-cli.zh.md
@@ -618,14 +618,14 @@ deepseekbot private-mcp-remove --server --confirm
#### Host 会话
```bash
-deepseekbot session-list
+deepseekbot session-list [--search <文本>] [--sort last-human-turn|created|last-activity] [--source all|native|bot:]
deepseekbot session-transcript --session
deepseekbot session-live --session [--after ]
deepseekbot session-send [--]
deepseekbot session-model --session [--set | --clear]
```
-这些命令通过已认证的在线 Host 执行。`session-list` 按 Human 最后发送消息的时间列出根会话,包含来源、已有标题、文件夹名称、运行状态、`lastPromptAt` 和 `updatedAt`。Host Owner 可以查看原生会话。团队成员可以查看自己的 Bot 会话,仍受现有会话隐私规则约束。读取原生会话、查看实时输出、发送消息和选择模型均需要 Host Owner 权限。DSH 接收原生会话消息后,命令返回 `requestId`。操作 Bot 会话时仍需传入 Bot ID。原生会话可选择 API 模型,`--clear` 恢复会话的原始模型。
+这些命令通过已认证的在线 Host 执行。`session-list` 默认按最近的 Human 消息时间降序列出根会话。用 `--sort created` 按创建时间降序排列,或用 `--sort last-activity` 按最近活动排序。`--search` 匹配会话标题和 Human 发送的消息,可与 `--source native` 或 `--source bot:` 组合。默认来源为 `all`。列表包含来源、已有标题、文件夹名称、运行状态、`lastPromptAt` 和 `updatedAt`。Host Owner 可以查看原生会话。团队成员可以查看自己的 Bot 会话,仍受现有会话隐私规则约束。读取原生会话、查看实时输出、发送消息和选择模型均需要 Host Owner 权限。DSH 接收原生会话消息后,命令返回 `requestId`。操作 Bot 会话时仍需传入 Bot ID。原生会话可选择 API 模型,`--clear` 恢复会话的原始模型。
`session-send ` 把 Human 的文字直接发进 Bot 当前的 Orchestrator Session,与该 Session 详情里的输入框相同。这是少用的主动 steer。任何 Channel 都不显示这段文字:Session 收到原文,前面只有一行说明这是 Human 在 Session 详情里写的;Bot Inbox 把它记为 Human 在其 DM 上的 Source Event,重启或 compaction 后仍在。无论 `human-dm` 投递设置如何,运行中的 turn 都在下一步收到它;Bot 正在准备或整理 Memory 时,它改为等到下一个 turn;空闲的 Orchestrator 会被唤醒。Bot 不必回复;带这个 `source_event_id` 的 `bot_send_message` 发到 Human 的 DM,不带引用。文字以 `-` 开头时,在它前面加 `--`;看起来像密钥参数的文字(如 `--token`、`--api-key=…`)仍以 `secret-in-argv` 拒绝,因为密钥从不经由参数传递。返回 `{ sourceEventId }`。Bot 能接收消息时,其他 Session 以 `invalid-input` 拒绝;Bot 此刻不能接收消息时(例如已暂停),以 `unavailable` 拒绝。
diff --git a/packages/core/src/bots/cli-inbox.ts b/packages/core/src/bots/cli-inbox.ts
index f4a64a72a2..f07b782d3b 100644
--- a/packages/core/src/bots/cli-inbox.ts
+++ b/packages/core/src/bots/cli-inbox.ts
@@ -1,4 +1,5 @@
import { sessionModelChoice } from '@botharness/host-protocol/session-model';
+import { isHostSessionFilter, isHostSessionSort } from '@botharness/host-protocol/host-sessions';
import {
readHumanAttention,
dismissHumanAttention,
@@ -87,7 +88,10 @@ export const INBOX_COMMANDS = [
},
{ command: 'channel-assignments', description: "list a group Channel's assignment work" },
{ command: 'channel-assign', description: 'move a Channel into a sidebar section or out of it' },
- { command: 'session-list', description: 'list accessible root Sessions on the Host' },
+ {
+ command: 'session-list',
+ description: 'list accessible root Sessions on the Host (--search, --sort, --source)',
+ },
{ command: 'session-ids', description: 'list the root Session IDs owned by Bots' },
{ command: 'session-owner', description: 'read which Bot owns a Session, and in which role' },
{
@@ -304,7 +308,9 @@ export async function runInboxCommand(
if (call.args['queryVersion'] === 1 && result['queryVersion'] !== 1)
throw new CliLiveError(
'host-query-unsupported',
- 'Update the Host to use Activity search, unread filtering and mention ordering.',
+ call.method === 'sessionList'
+ ? 'Update the Host to search, sort and filter Sessions.'
+ : 'Update the Host to use Activity search, unread filtering and mention ordering.',
);
if (call.method === 'privateMcpServerEnable' && result['accepted'] !== true)
throw new CliLiveError(
@@ -548,9 +554,25 @@ function prepare(
usage('session-model --set needs a model, engine or Routing Group choice.');
return { method: 'sessionModel', args: { slug, sessionId, choice } };
}
- case 'session-list':
+ case 'session-list': {
positionals(command, rest, 0, '');
- return { method: 'sessionList', args: {} };
+ const { search, sort, source } = values;
+ if (sort !== undefined && !isHostSessionSort(sort))
+ usage('session-list --sort must be last-human-turn, created, or last-activity.');
+ if (source !== undefined && !isHostSessionFilter(source))
+ usage('session-list --source must be all, native, or bot:.');
+ return {
+ method: 'sessionList',
+ args: {
+ ...(search === undefined ? {} : { search }),
+ ...(sort === undefined ? {} : { sort }),
+ ...(source === undefined ? {} : { source }),
+ ...(search === undefined && sort === undefined && source === undefined
+ ? {}
+ : { queryVersion: 1 }),
+ },
+ };
+ }
case 'session-transcript': {
const [slug = null] = positionals(
command,
diff --git a/packages/core/src/features/sessions/dsh-host-session-query.ts b/packages/core/src/features/sessions/dsh-host-session-query.ts
new file mode 100644
index 0000000000..d278ee119a
--- /dev/null
+++ b/packages/core/src/features/sessions/dsh-host-session-query.ts
@@ -0,0 +1,90 @@
+import { SessionId, type SessionEvent } from '@deepseek-ai/dsh-session';
+import { SessionQueryError, type SessionQueryEngine } from '@deepseek-ai/dsh-session-query';
+import { scheduler } from 'node:timers/promises';
+import { inboxWakeBody, parseInboundEnvelope } from '../../runtime/inbound-envelope.js';
+import { sessionDirectBody } from '../../runtime/session-direct-message.js';
+import { normalizeSessionSearch, type NativeSessions } from './host-sessions.js';
+
+type Query = Pick;
+type SessionQueryMethods = Required>;
+
+function humanText(
+ event: SessionEvent,
+ source: 'native' | 'bot',
+ readHumanMessage: (channelId: string, messageId: string) => string | undefined,
+): string | undefined {
+ if (event.type !== 'user/message' || event.data.source.kind !== 'user') return undefined;
+ const text = event.data.content.flatMap((part) => (part.type === 'text' ? [part.text] : []));
+ if (source === 'native') return text.join('\n');
+ const prompt = text[0];
+ if (prompt === undefined || inboxWakeBody(prompt) !== undefined) return undefined;
+ const direct = sessionDirectBody(prompt);
+ if (direct !== undefined) return direct;
+ const envelope = parseInboundEnvelope(prompt);
+ if (envelope?.channelId === undefined || envelope.messageId === undefined) return undefined;
+ if (envelope.kind !== 'human-dm' && envelope.kind !== 'group' && envelope.kind !== 'inbox')
+ return undefined;
+ return readHumanMessage(envelope.channelId, envelope.messageId);
+}
+
+const OBSERVATION_BATCH_SIZE = 4;
+
+async function observeSessions(
+ query: Query,
+ ids: readonly string[],
+ inspect: (id: string, events: readonly SessionEvent[], createdAt: number) => T,
+): Promise