mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-14 02:38:20 +02:00
Jauge de contexte, espace disque sur partage agrégé, panneau Fichiers
Trois défauts sans rapport entre eux, tous visibles à l'écran. Jauge de contexte bloquée à « 0 / N (0 %) » : le comptage exact vient de usage.prompt_tokens (include_usage), qu'un llama-server récent a cessé de renvoyer. On note désormais si l'usage est arrivé ; sinon la fin de tour publie l'estimation qui pilote déjà la compaction — approximative, mais jamais absente. Et la souscription envoie la valeur courante juste après le rattrapage : une page rechargée affichait zéro sur une discussion pourtant pleine, faute d'événement ctx_used dans la fenêtre rejouée. Espace disque : « il ne reste que 11,9 Go » sur un partage Unraid qui en a des centaines. /mnt/user est servi par shfs, un FUSE qui agrège plusieurs disques — statfs y renvoie l'espace d'un seul, et ce chiffre REFUSAIT l'installation du modèle. Les systèmes de fichiers qui approximent (FUSE, overlay, NFS, CIFS, Ceph, Gluster) sont reconnus par leur magie : leur chiffre reste affiché, précédé d'un « ~ », mais ne bloque plus rien. Panneau Fichiers : le panneau entier défilait, emportant vers le haut l'en-tête, le fil d'Ariane et le pied (occupation disque, bouton .zip) dès qu'il y avait quelques fichiers. Seule la liste défile maintenant ; le pied reste en bas et l'état vide se centre. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
895ff92ed8
commit
b405adea6c
5118 files changed
+1264007
-23
No files matched your search
+117
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* @typedef CoreOptions
|
||||
* @property {ReadonlyArray<string>} [subset=[]]
|
||||
* Whether to only escape the given subset of characters.
|
||||
* @property {boolean} [escapeOnly=false]
|
||||
* Whether to only escape possibly dangerous characters.
|
||||
* Those characters are `"`, `&`, `'`, `<`, `>`, and `` ` ``.
|
||||
*
|
||||
* @typedef FormatOptions
|
||||
* @property {(code: number, next: number, options: CoreWithFormatOptions) => string} format
|
||||
* Format strategy.
|
||||
*
|
||||
* @typedef {CoreOptions & FormatOptions & import('./util/format-smart.js').FormatSmartOptions} CoreWithFormatOptions
|
||||
*/
|
||||
|
||||
const defaultSubsetRegex = /["&'<>`]/g
|
||||
const surrogatePairsRegex = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g
|
||||
const controlCharactersRegex =
|
||||
// eslint-disable-next-line no-control-regex, unicorn/no-hex-escape
|
||||
/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g
|
||||
const regexEscapeRegex = /[|\\{}()[\]^$+*?.]/g
|
||||
|
||||
/** @type {WeakMap<ReadonlyArray<string>, RegExp>} */
|
||||
const subsetToRegexCache = new WeakMap()
|
||||
|
||||
/**
|
||||
* Encode certain characters in `value`.
|
||||
*
|
||||
* @param {string} value
|
||||
* @param {CoreWithFormatOptions} options
|
||||
* @returns {string}
|
||||
*/
|
||||
export function core(value, options) {
|
||||
value = value.replace(
|
||||
options.subset
|
||||
? charactersToExpressionCached(options.subset)
|
||||
: defaultSubsetRegex,
|
||||
basic
|
||||
)
|
||||
|
||||
if (options.subset || options.escapeOnly) {
|
||||
return value
|
||||
}
|
||||
|
||||
return (
|
||||
value
|
||||
// Surrogate pairs.
|
||||
.replace(surrogatePairsRegex, surrogate)
|
||||
// BMP control characters (C0 except for LF, CR, SP; DEL; and some more
|
||||
// non-ASCII ones).
|
||||
.replace(controlCharactersRegex, basic)
|
||||
)
|
||||
|
||||
/**
|
||||
* @param {string} pair
|
||||
* @param {number} index
|
||||
* @param {string} all
|
||||
*/
|
||||
function surrogate(pair, index, all) {
|
||||
return options.format(
|
||||
(pair.charCodeAt(0) - 0xd800) * 0x400 +
|
||||
pair.charCodeAt(1) -
|
||||
0xdc00 +
|
||||
0x10000,
|
||||
all.charCodeAt(index + 2),
|
||||
options
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} character
|
||||
* @param {number} index
|
||||
* @param {string} all
|
||||
*/
|
||||
function basic(character, index, all) {
|
||||
return options.format(
|
||||
character.charCodeAt(0),
|
||||
all.charCodeAt(index + 1),
|
||||
options
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper function that caches the result of `charactersToExpression` with a WeakMap.
|
||||
* This can improve performance when tooling calls `charactersToExpression` repeatedly
|
||||
* with the same subset.
|
||||
*
|
||||
* @param {ReadonlyArray<string>} subset
|
||||
* @returns {RegExp}
|
||||
*/
|
||||
function charactersToExpressionCached(subset) {
|
||||
let cached = subsetToRegexCache.get(subset)
|
||||
|
||||
if (!cached) {
|
||||
cached = charactersToExpression(subset)
|
||||
subsetToRegexCache.set(subset, cached)
|
||||
}
|
||||
|
||||
return cached
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ReadonlyArray<string>} subset
|
||||
* @returns {RegExp}
|
||||
*/
|
||||
function charactersToExpression(subset) {
|
||||
/** @type {Array<string>} */
|
||||
const groups = []
|
||||
let index = -1
|
||||
|
||||
while (++index < subset.length) {
|
||||
groups.push(subset[index].replace(regexEscapeRegex, '\\$&'))
|
||||
}
|
||||
|
||||
return new RegExp('(?:' + groups.join('|') + ')', 'g')
|
||||
}
|
||||
Reference in new issue
Block a user