mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(codex): support file mentions (#774)
* feat(codex): support file mentions * fix(codex): quote file mention paths with spaces * fix(codex): keep punctuation outside file mentions * fix(codex): avoid parsing literal at-mentions * fix(codex): scope file mention autocomplete
This commit is contained in:
+16
-1
@@ -971,11 +971,26 @@ function SessionPage() {
|
||||
} = useSkills(api, sessionId)
|
||||
|
||||
const getAutocompleteSuggestions = useCallback(async (query: string) => {
|
||||
if (query.startsWith('@')) {
|
||||
if (agentType !== 'codex' || !api || !sessionId) return []
|
||||
const search = query.slice(1)
|
||||
const response = await api.searchSessionFiles(sessionId, search, 50)
|
||||
if (!response.success || !response.files) return []
|
||||
return response.files.map((file) => {
|
||||
const mentionText = `@"${file.fullPath.replace(/(["\\])/g, '\\$1')}"`
|
||||
return {
|
||||
key: mentionText,
|
||||
text: mentionText,
|
||||
label: `@${file.fileName}`,
|
||||
description: file.filePath || file.fullPath
|
||||
}
|
||||
})
|
||||
}
|
||||
if (query.startsWith('$')) {
|
||||
return await getSkillSuggestions(query)
|
||||
}
|
||||
return await getSlashSuggestions(query)
|
||||
}, [getSkillSuggestions, getSlashSuggestions])
|
||||
}, [agentType, api, sessionId, getSkillSuggestions, getSlashSuggestions])
|
||||
|
||||
const refreshSelectedSession = useCallback(() => {
|
||||
void refetchSession()
|
||||
|
||||
Reference in New Issue
Block a user