冲突是载体搬迁,不是语义作废:
- `@` 回调的载体在 dev 已是 src/client/reference-in-chat.ts(#479 eed2fee 抽出的
两侧共享入口)。PR 新增的 `insertWorkspaceReference` 与 `directoryMention`
落在 conversation-draft.ts(它要用同模块的 appendToDraft /
insertFileReference / mentionFor),由该入口转发;Sidebar.tsx 只保留转发,
native/tab-adapter.tsx 与之同步,两个调用点不再传 cwd(工作区 root 由
`ctx.get('workspaces')` 的会话成员匹配得到,不再回退会话 cwd)。
- PR 的 `directoryMention` 改为委托 dev 的共用构造器 `mentionFor(path, 'folder')`
(#479 把「尾斜杠进引号」的规则收进它),不再自建一套引号规则;
`insertWorkspaceReference` 的文件分支同样换成 `mentionFor(path, 'file')`。
- tests/paths.spec.ts:`resolveSidebarPath` 的导入走已搬迁的 src/client/paths.ts
(produced-files.ts 已不存在),并存的 preview URL 用例与 workspaceRelativePath
用例两块都保留。
- tests/reference-in-chat.spec.ts(#479 验收 spec):fake ctx 补上它现在要读的
workspaces 面、调用点去掉 cwd,三处草稿断言跟随本 PR 的目录尾随分隔空格;
引号与宿主 token 可读性的断言逐字未动。
Refs #574
45 lines
2.0 KiB
TypeScript
45 lines
2.0 KiB
TypeScript
/**
|
|
* The explorer's `@`-reference button: insert one file or folder reference
|
|
* into the conversation draft of a session.
|
|
*
|
|
* The token is projected against the host-confirmed workspace root — the
|
|
* session's `WorkspaceView.path`, matched by exact session membership — never
|
|
* the session cwd: DSH's `@` grammar is workspace-root relative (#479), and a
|
|
* cwd-relative guess silently names a different file whenever the two differ.
|
|
* A missing service or membership, an unready snapshot, a path outside the
|
|
* workspace and an unrepresentable path all degrade to a logged no-op, never
|
|
* an absolute mention. `insertWorkspaceReference` owns that policy; this
|
|
* module stays the single entry both surfaces share.
|
|
*
|
|
* Directories append the folder mention as plain text so DSH's folder
|
|
* decoration and completion keep working — spelled through the same
|
|
* constructor as file references (`@"my dir/"`, `@docs/`; an unquoted
|
|
* `@my dir/` is not a folder token to the host, see `mentionFor`); files
|
|
* insert a structured chip like the native `@` picker, so the whole
|
|
* reference stays one link instead of decorating only the leading folder.
|
|
* The session-scope context and the conversation input service are resolved
|
|
* at click time; a missing service or scope degrades to a logged no-op,
|
|
* never a crash.
|
|
*
|
|
* Shared by the plugin's own panel and the native right-Sidebar tab body, so
|
|
* both surfaces behave identically.
|
|
*/
|
|
import type { Context } from '../context-types.ts'
|
|
import { insertWorkspaceReference } from './conversation-draft.ts'
|
|
|
|
/**
|
|
* Reference one path in the session's conversation draft.
|
|
* @param ctx - the client context.
|
|
* @param sessionId - the session whose draft receives the reference.
|
|
* @param path - the absolute entry path the explorer row carries.
|
|
* @param isDir - whether the path is a directory (folder mention vs file chip).
|
|
*/
|
|
export function referenceInChat(
|
|
ctx: Context,
|
|
sessionId: string,
|
|
path: string,
|
|
isDir: boolean,
|
|
): void {
|
|
insertWorkspaceReference(ctx, sessionId, path, isDir)
|
|
}
|