Files
opencode-manager/frontend/src/lib/fileReferences.ts
T
Chris Scott 03bd3dac95 feat(frontend): improve model selection experience (#237)
* chore: remove dead code and unused exports

* fix: preserve model form during config refresh

Signed-off-by: mehmet turac <mehmetturac@gmail.com>

* loop: model-select-fix completed after 11 iterations

* fix(frontend): show provider prefix for duplicate models in quick select dropdown

When the same model exists under multiple providers, show the provider name
for both entries so users can distinguish them. Detects duplicates by modelID
across all favorites and recents.

* refactor(frontend): replace useTallScrollContent with scroll visibility hook

* fix: harden mirror push rollback

* Remove Load button from skill cards, clicking card loads skill

* feat(backend): add plugin installation support and schema updates

* refactor(frontend): remove unused useHeaderScrollVisibility hook

* refactor(frontend): replace model dropdown with bottom sheet selector

Replace DropdownMenu-based ModelQuickSelect with a bottom sheet
implementation featuring favorites, recents, provider browsing, and
search. Remove onShowModelsDialog prop from PromptInput and
SessionDetail, using data attribute trigger instead. Fix ZodIssueCode
deprecation, input text color, and portal rendering for bottom sheet.

* fix(frontend): simplify session model restore and fix mobile swipe reset

* loop: single-source-models completed after 10 iterations

* refactor(frontend): add desktop sidebar layout to model quick select

* refactor(frontend): improve model selector with connected providers, favorites, and recent management

* fix(frontend): constrain model name width to prevent overflow in prompt input

* fix(frontend): adjust padding and styling in model quick select

* fix(frontend): add optimistic removal with rollback for recent models

---------
2026-05-25 09:47:59 -04:00

34 lines
932 B
TypeScript

export interface FileReference {
filePath: string
lineNumber?: number
startIndex: number
endIndex: number
fullMatch: string
}
const FILE_REFERENCE_PATTERN = /\b([\w\-./]+\.(ts|tsx|js|jsx|py|java|cpp|c|h|hpp|go|rs|rb|php|swift|kt|cs|vue|svelte|css|scss|sass|less|html|xml|json|yaml|yml|md|txt|sh|bash|sql|graphql|proto|toml|ini|conf|env))(?::(\d+))?\b/gi
export function detectFileReferences(text: string): FileReference[] {
const references: FileReference[] = []
const regex = new RegExp(FILE_REFERENCE_PATTERN)
let match: RegExpExecArray | null
while ((match = regex.exec(text)) !== null) {
const fullMatch = match[0]
const filePath = match[1]
const lineNumber = match[3] ? parseInt(match[3], 10) : undefined
references.push({
filePath,
lineNumber,
startIndex: match.index,
endIndex: match.index + fullMatch.length,
fullMatch,
})
}
return references
}