dsh-sidenote 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +118 -116
- package/package.json +1 -1
- package/src/client/sidechat/PermissionChip.tsx +13 -13
package/lib/client.js
CHANGED
|
@@ -619,7 +619,7 @@ window.__ModuleLoader__.load({
|
|
|
619
619
|
let dockRegistered = false;
|
|
620
620
|
let report = {
|
|
621
621
|
versions: {
|
|
622
|
-
sidenote: "0.5.
|
|
622
|
+
sidenote: "0.5.1",
|
|
623
623
|
dsh: "unknown",
|
|
624
624
|
betterSidebar: null
|
|
625
625
|
},
|
|
@@ -1229,13 +1229,13 @@ window.__ModuleLoader__.load({
|
|
|
1229
1229
|
}
|
|
1230
1230
|
var diagnostics_module_css_default = {
|
|
1231
1231
|
"setting": "tGe0LW_setting",
|
|
1232
|
-
"
|
|
1233
|
-
"settingTitle": "tGe0LW_settingTitle",
|
|
1232
|
+
"versions": "tGe0LW_versions",
|
|
1234
1233
|
"trigger": "tGe0LW_trigger",
|
|
1235
1234
|
"panel": "tGe0LW_panel",
|
|
1236
|
-
"
|
|
1237
|
-
"versions": "tGe0LW_versions",
|
|
1235
|
+
"actions": "tGe0LW_actions",
|
|
1238
1236
|
"list": "tGe0LW_list",
|
|
1237
|
+
"header": "tGe0LW_header",
|
|
1238
|
+
"settingTitle": "tGe0LW_settingTitle",
|
|
1239
1239
|
"description": "tGe0LW_description"
|
|
1240
1240
|
};
|
|
1241
1241
|
//#endregion
|
|
@@ -3219,96 +3219,96 @@ window.__ModuleLoader__.load({
|
|
|
3219
3219
|
document.head.appendChild(tag);
|
|
3220
3220
|
}
|
|
3221
3221
|
var sidechat_module_css_default = {
|
|
3222
|
-
"
|
|
3223
|
-
"
|
|
3224
|
-
"
|
|
3225
|
-
"
|
|
3226
|
-
"nativeHost": "_5KEEsG_nativeHost",
|
|
3227
|
-
"parentStrip": "_5KEEsG_parentStrip",
|
|
3228
|
-
"sidechat-pulse": "_5KEEsG_sidechat-pulse",
|
|
3229
|
-
"userRow": "_5KEEsG_userRow",
|
|
3230
|
-
"slashItemName": "_5KEEsG_slashItemName",
|
|
3231
|
-
"actionGroup": "_5KEEsG_actionGroup",
|
|
3232
|
-
"headerSide": "_5KEEsG_headerSide",
|
|
3233
|
-
"slashItem": "_5KEEsG_slashItem",
|
|
3234
|
-
"composer": "_5KEEsG_composer",
|
|
3222
|
+
"pendingDesc": "_5KEEsG_pendingDesc",
|
|
3223
|
+
"quoteBody": "_5KEEsG_quoteBody",
|
|
3224
|
+
"toolBody": "_5KEEsG_toolBody",
|
|
3225
|
+
"pendingActions": "_5KEEsG_pendingActions",
|
|
3235
3226
|
"densityToggle": "_5KEEsG_densityToggle",
|
|
3236
|
-
"
|
|
3227
|
+
"toolHead": "_5KEEsG_toolHead",
|
|
3228
|
+
"emptyText": "_5KEEsG_emptyText",
|
|
3229
|
+
"userBubble": "_5KEEsG_userBubble",
|
|
3230
|
+
"modelLabel": "_5KEEsG_modelLabel",
|
|
3237
3231
|
"sentChip": "_5KEEsG_sentChip",
|
|
3238
|
-
"
|
|
3239
|
-
"input": "_5KEEsG_input",
|
|
3232
|
+
"todoBody": "_5KEEsG_todoBody",
|
|
3240
3233
|
"todoDot": "_5KEEsG_todoDot",
|
|
3241
|
-
"
|
|
3242
|
-
"pendingBtnPrimary": "_5KEEsG_pendingBtnPrimary",
|
|
3243
|
-
"pendingBtnGhost": "_5KEEsG_pendingBtnGhost",
|
|
3244
|
-
"stateDetail": "_5KEEsG_stateDetail",
|
|
3245
|
-
"pendingBar": "_5KEEsG_pendingBar",
|
|
3246
|
-
"jumpBottom": "_5KEEsG_jumpBottom",
|
|
3247
|
-
"writeNoticeClose": "_5KEEsG_writeNoticeClose",
|
|
3248
|
-
"quoteBody": "_5KEEsG_quoteBody",
|
|
3234
|
+
"attachRail": "_5KEEsG_attachRail",
|
|
3249
3235
|
"attachRemove": "_5KEEsG_attachRemove",
|
|
3250
|
-
"noticeRow": "_5KEEsG_noticeRow",
|
|
3251
|
-
"emptyIcon": "_5KEEsG_emptyIcon",
|
|
3252
|
-
"assistantBody": "_5KEEsG_assistantBody",
|
|
3253
|
-
"assistantRow": "_5KEEsG_assistantRow",
|
|
3254
|
-
"errorRow": "_5KEEsG_errorRow",
|
|
3255
|
-
"todoItem": "_5KEEsG_todoItem",
|
|
3256
|
-
"pendingHead": "_5KEEsG_pendingHead",
|
|
3257
|
-
"pendingDesc": "_5KEEsG_pendingDesc",
|
|
3258
|
-
"sentChipRow": "_5KEEsG_sentChipRow",
|
|
3259
|
-
"flowRow": "_5KEEsG_flowRow",
|
|
3260
|
-
"pendingCustom": "_5KEEsG_pendingCustom",
|
|
3261
|
-
"todoText": "_5KEEsG_todoText",
|
|
3262
|
-
"slashItemActive": "_5KEEsG_slashItemActive",
|
|
3263
|
-
"writeNotice": "_5KEEsG_writeNotice",
|
|
3264
|
-
"toolGenericBody": "_5KEEsG_toolGenericBody",
|
|
3265
|
-
"emptyTitle": "_5KEEsG_emptyTitle",
|
|
3266
|
-
"pendingActions": "_5KEEsG_pendingActions",
|
|
3267
|
-
"toolCard": "_5KEEsG_toolCard",
|
|
3268
|
-
"attachImg": "_5KEEsG_attachImg",
|
|
3269
|
-
"pendingOption": "_5KEEsG_pendingOption",
|
|
3270
|
-
"pendingQHeader": "_5KEEsG_pendingQHeader",
|
|
3271
3236
|
"reasoningBody": "_5KEEsG_reasoningBody",
|
|
3272
|
-
"
|
|
3237
|
+
"pendingReason": "_5KEEsG_pendingReason",
|
|
3273
3238
|
"composerFoot": "_5KEEsG_composerFoot",
|
|
3274
|
-
"snapshotBody": "_5KEEsG_snapshotBody",
|
|
3275
|
-
"transcript": "_5KEEsG_transcript",
|
|
3276
|
-
"toolHead": "_5KEEsG_toolHead",
|
|
3277
|
-
"reasoning": "_5KEEsG_reasoning",
|
|
3278
|
-
"toolBodyText": "_5KEEsG_toolBodyText",
|
|
3279
|
-
"inheritedBody": "_5KEEsG_inheritedBody",
|
|
3280
|
-
"pendingOptionActive": "_5KEEsG_pendingOptionActive",
|
|
3281
|
-
"toolLocations": "_5KEEsG_toolLocations",
|
|
3282
|
-
"dotIdle": "_5KEEsG_dotIdle",
|
|
3283
|
-
"emptyText": "_5KEEsG_emptyText",
|
|
3284
|
-
"body": "_5KEEsG_body",
|
|
3285
|
-
"stopButton": "_5KEEsG_stopButton",
|
|
3286
|
-
"rowPreview": "_5KEEsG_rowPreview",
|
|
3287
|
-
"dotRunning": "_5KEEsG_dotRunning",
|
|
3288
|
-
"pendingCard": "_5KEEsG_pendingCard",
|
|
3289
|
-
"slashGroupTitle": "_5KEEsG_slashGroupTitle",
|
|
3290
3239
|
"pendingQText": "_5KEEsG_pendingQText",
|
|
3291
|
-
"root": "_5KEEsG_root",
|
|
3292
|
-
"pendingQuestion": "_5KEEsG_pendingQuestion",
|
|
3293
3240
|
"reflowButton": "_5KEEsG_reflowButton",
|
|
3294
|
-
"
|
|
3295
|
-
"attachRail": "_5KEEsG_attachRail",
|
|
3296
|
-
"modelSelect": "_5KEEsG_modelSelect",
|
|
3297
|
-
"userBubble": "_5KEEsG_userBubble",
|
|
3298
|
-
"composerChips": "_5KEEsG_composerChips",
|
|
3241
|
+
"sidechat-pulse": "_5KEEsG_sidechat-pulse",
|
|
3299
3242
|
"composerCard": "_5KEEsG_composerCard",
|
|
3300
|
-
"
|
|
3301
|
-
"flowRowError": "_5KEEsG_flowRowError",
|
|
3302
|
-
"streamingHint": "_5KEEsG_streamingHint",
|
|
3303
|
-
"toolBody": "_5KEEsG_toolBody",
|
|
3304
|
-
"todoBody": "_5KEEsG_todoBody",
|
|
3305
|
-
"toolError": "_5KEEsG_toolError",
|
|
3243
|
+
"attachImg": "_5KEEsG_attachImg",
|
|
3306
3244
|
"slashItemDetail": "_5KEEsG_slashItemDetail",
|
|
3307
|
-
"
|
|
3245
|
+
"flowRowError": "_5KEEsG_flowRowError",
|
|
3246
|
+
"emptyIcon": "_5KEEsG_emptyIcon",
|
|
3247
|
+
"writeNoticeClose": "_5KEEsG_writeNoticeClose",
|
|
3308
3248
|
"densityRow": "_5KEEsG_densityRow",
|
|
3249
|
+
"composer": "_5KEEsG_composer",
|
|
3250
|
+
"parentStrip": "_5KEEsG_parentStrip",
|
|
3251
|
+
"composerChips": "_5KEEsG_composerChips",
|
|
3252
|
+
"dotPending": "_5KEEsG_dotPending",
|
|
3253
|
+
"snapshotText": "_5KEEsG_snapshotText",
|
|
3254
|
+
"flowRow": "_5KEEsG_flowRow",
|
|
3255
|
+
"sendButton": "_5KEEsG_sendButton",
|
|
3256
|
+
"pendingQuestion": "_5KEEsG_pendingQuestion",
|
|
3309
3257
|
"pendingTitle": "_5KEEsG_pendingTitle",
|
|
3258
|
+
"noticeRow": "_5KEEsG_noticeRow",
|
|
3259
|
+
"pendingBtnPrimary": "_5KEEsG_pendingBtnPrimary",
|
|
3260
|
+
"emptyTitle": "_5KEEsG_emptyTitle",
|
|
3261
|
+
"rowActions": "_5KEEsG_rowActions",
|
|
3262
|
+
"snapshotBody": "_5KEEsG_snapshotBody",
|
|
3263
|
+
"dotRunning": "_5KEEsG_dotRunning",
|
|
3264
|
+
"headerSide": "_5KEEsG_headerSide",
|
|
3265
|
+
"actionGroup": "_5KEEsG_actionGroup",
|
|
3266
|
+
"attachButton": "_5KEEsG_attachButton",
|
|
3267
|
+
"todoText": "_5KEEsG_todoText",
|
|
3268
|
+
"slashItem": "_5KEEsG_slashItem",
|
|
3269
|
+
"root": "_5KEEsG_root",
|
|
3270
|
+
"pendingHead": "_5KEEsG_pendingHead",
|
|
3271
|
+
"pendingOptionDesc": "_5KEEsG_pendingOptionDesc",
|
|
3272
|
+
"stopButton": "_5KEEsG_stopButton",
|
|
3273
|
+
"slashItemName": "_5KEEsG_slashItemName",
|
|
3274
|
+
"modelSelect": "_5KEEsG_modelSelect",
|
|
3275
|
+
"pendingBtnGhost": "_5KEEsG_pendingBtnGhost",
|
|
3276
|
+
"input": "_5KEEsG_input",
|
|
3277
|
+
"pendingBar": "_5KEEsG_pendingBar",
|
|
3278
|
+
"slashMenu": "_5KEEsG_slashMenu",
|
|
3279
|
+
"body": "_5KEEsG_body",
|
|
3280
|
+
"sentChipRow": "_5KEEsG_sentChipRow",
|
|
3281
|
+
"toolLocations": "_5KEEsG_toolLocations",
|
|
3282
|
+
"attachThumb": "_5KEEsG_attachThumb",
|
|
3283
|
+
"pendingOptionActive": "_5KEEsG_pendingOptionActive",
|
|
3284
|
+
"errorRow": "_5KEEsG_errorRow",
|
|
3285
|
+
"rowPreview": "_5KEEsG_rowPreview",
|
|
3286
|
+
"transcript": "_5KEEsG_transcript",
|
|
3287
|
+
"toolError": "_5KEEsG_toolError",
|
|
3288
|
+
"streamingHint": "_5KEEsG_streamingHint",
|
|
3289
|
+
"toolCard": "_5KEEsG_toolCard",
|
|
3290
|
+
"empty": "_5KEEsG_empty",
|
|
3291
|
+
"assistantBody": "_5KEEsG_assistantBody",
|
|
3292
|
+
"userRow": "_5KEEsG_userRow",
|
|
3293
|
+
"todoItem": "_5KEEsG_todoItem",
|
|
3294
|
+
"assistantRow": "_5KEEsG_assistantRow",
|
|
3295
|
+
"inheritedBody": "_5KEEsG_inheritedBody",
|
|
3296
|
+
"toolRunning": "_5KEEsG_toolRunning",
|
|
3297
|
+
"jumpBottom": "_5KEEsG_jumpBottom",
|
|
3298
|
+
"pendingCard": "_5KEEsG_pendingCard",
|
|
3299
|
+
"pendingOption": "_5KEEsG_pendingOption",
|
|
3300
|
+
"writeNotice": "_5KEEsG_writeNotice",
|
|
3301
|
+
"toolGenericBody": "_5KEEsG_toolGenericBody",
|
|
3302
|
+
"dotIdle": "_5KEEsG_dotIdle",
|
|
3303
|
+
"stateDetail": "_5KEEsG_stateDetail",
|
|
3304
|
+
"slashGroupTitle": "_5KEEsG_slashGroupTitle",
|
|
3305
|
+
"pendingCustom": "_5KEEsG_pendingCustom",
|
|
3306
|
+
"reasoning": "_5KEEsG_reasoning",
|
|
3310
3307
|
"stateScreen": "_5KEEsG_stateScreen",
|
|
3311
|
-
"
|
|
3308
|
+
"slashItemActive": "_5KEEsG_slashItemActive",
|
|
3309
|
+
"toolBodyText": "_5KEEsG_toolBodyText",
|
|
3310
|
+
"pendingQHeader": "_5KEEsG_pendingQHeader",
|
|
3311
|
+
"nativeHost": "_5KEEsG_nativeHost"
|
|
3312
3312
|
};
|
|
3313
3313
|
//#endregion
|
|
3314
3314
|
//#region src/client/chat/ToolCard.tsx
|
|
@@ -5119,17 +5119,17 @@ ${entries.map((entry) => {
|
|
|
5119
5119
|
document.head.appendChild(tag);
|
|
5120
5120
|
}
|
|
5121
5121
|
var annotations_module_css_default = {
|
|
5122
|
-
"chipPanel": "SVnebq_chipPanel",
|
|
5123
|
-
"storageNotice": "SVnebq_storageNotice",
|
|
5124
|
-
"side": "SVnebq_side",
|
|
5125
|
-
"chipWrap": "SVnebq_chipWrap",
|
|
5126
5122
|
"chipRow": "SVnebq_chipRow",
|
|
5127
|
-
"chipNumber": "SVnebq_chipNumber",
|
|
5128
|
-
"chipClearAll": "SVnebq_chipClearAll",
|
|
5129
5123
|
"chipRemove": "SVnebq_chipRemove",
|
|
5130
|
-
"
|
|
5124
|
+
"chipClearAll": "SVnebq_chipClearAll",
|
|
5125
|
+
"chipPanel": "SVnebq_chipPanel",
|
|
5126
|
+
"chipNumber": "SVnebq_chipNumber",
|
|
5127
|
+
"chipWrap": "SVnebq_chipWrap",
|
|
5131
5128
|
"chip": "SVnebq_chip",
|
|
5132
|
-
"
|
|
5129
|
+
"chipText": "SVnebq_chipText",
|
|
5130
|
+
"chipNote": "SVnebq_chipNote",
|
|
5131
|
+
"side": "SVnebq_side",
|
|
5132
|
+
"storageNotice": "SVnebq_storageNotice"
|
|
5133
5133
|
};
|
|
5134
5134
|
//#endregion
|
|
5135
5135
|
//#region src/client/annotations/chip.tsx
|
|
@@ -5334,15 +5334,17 @@ ${entries.map((entry) => {
|
|
|
5334
5334
|
* 点击弹 Menu 切换(原生同路径:`session.command('/permission <id>')`)。
|
|
5335
5335
|
*
|
|
5336
5336
|
* 数据:session.projections.faceOf('permissions')(off-face——缺席则 chip
|
|
5337
|
-
*
|
|
5338
|
-
*
|
|
5337
|
+
* 不渲染)。快照 = 宿主的 wire view,只有一个 currentValue 字段
|
|
5338
|
+
* (dsh-permission-presets 的 wire.viewSchema = { currentValue };权威见
|
|
5339
|
+
* 该包 lib/types 的 selectionSchema)——{preset, sandbox, approval} 是投影
|
|
5340
|
+
* **内部 state**(stateSchema),客户端拿不到,读它会让 chip 恒显示默认档。
|
|
5339
5341
|
*/
|
|
5340
5342
|
/** preset 机器值 → 展示名(宿主 displayPermissionPreset 同款:Full access 特例)。 */
|
|
5341
5343
|
function presetLabel(preset) {
|
|
5342
5344
|
if (preset === "danger-full-access") return t("permFullAccess");
|
|
5343
5345
|
return preset.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
5344
5346
|
}
|
|
5345
|
-
/**
|
|
5347
|
+
/** 宿主默认表里 chip 菜单列出的档位(其余档位仍可由 /permission 切换)。 */
|
|
5346
5348
|
const KNOWN_PRESETS = ["workspace-write", "danger-full-access"];
|
|
5347
5349
|
function PermissionChip(props) {
|
|
5348
5350
|
useLocaleTick();
|
|
@@ -5351,9 +5353,9 @@ ${entries.map((entry) => {
|
|
|
5351
5353
|
const p = props.session;
|
|
5352
5354
|
return typeof p?.projections?.faceOf === "function" ? p.projections.faceOf("permissions") : void 0;
|
|
5353
5355
|
}, [props.session]);
|
|
5354
|
-
const
|
|
5355
|
-
if (face === void 0 ||
|
|
5356
|
-
const effective =
|
|
5356
|
+
const snapshot = (0, react.useSyncExternalStore)((fn) => face?.subscribe(fn) ?? (() => {}), () => face?.getSnapshot() ?? null);
|
|
5357
|
+
if (face === void 0 || snapshot === null) return null;
|
|
5358
|
+
const effective = snapshot.currentValue ?? "workspace-write";
|
|
5357
5359
|
const items = KNOWN_PRESETS.map((id) => ({
|
|
5358
5360
|
id,
|
|
5359
5361
|
label: presetLabel(id) + (id === effective ? " ✓" : "")
|
|
@@ -7635,34 +7637,34 @@ ${entries.map((entry) => {
|
|
|
7635
7637
|
document.head.appendChild(tag);
|
|
7636
7638
|
}
|
|
7637
7639
|
var annotate_module_css_default = {
|
|
7640
|
+
"editorInput": "_SVViG_editorInput",
|
|
7641
|
+
"editorTextarea": "_SVViG_editorTextarea",
|
|
7642
|
+
"hintClose": "_SVViG_hintClose",
|
|
7643
|
+
"toolbarBelow": "_SVViG_toolbarBelow",
|
|
7638
7644
|
"badge": "_SVViG_badge",
|
|
7639
|
-
"
|
|
7645
|
+
"editorNew": "_SVViG_editorNew",
|
|
7646
|
+
"editorEdit": "_SVViG_editorEdit",
|
|
7640
7647
|
"deleteButton": "_SVViG_deleteButton",
|
|
7641
|
-
"
|
|
7642
|
-
"editorTextarea": "_SVViG_editorTextarea",
|
|
7648
|
+
"toolbar": "_SVViG_toolbar",
|
|
7643
7649
|
"cancelButton": "_SVViG_cancelButton",
|
|
7644
|
-
"
|
|
7645
|
-
"
|
|
7650
|
+
"saveButton": "_SVViG_saveButton",
|
|
7651
|
+
"sentChip": "_SVViG_sentChip",
|
|
7646
7652
|
"sentCardTitle": "_SVViG_sentCardTitle",
|
|
7647
|
-
"
|
|
7648
|
-
"
|
|
7649
|
-
"editorInput": "_SVViG_editorInput",
|
|
7650
|
-
"toolbarBelow": "_SVViG_toolbarBelow",
|
|
7651
|
-
"toolbarButton": "_SVViG_toolbarButton",
|
|
7653
|
+
"highlight": "_SVViG_highlight",
|
|
7654
|
+
"dshSidenoteHintIn": "_SVViG_dshSidenoteHintIn",
|
|
7652
7655
|
"confirmButton": "_SVViG_confirmButton",
|
|
7653
|
-
"
|
|
7656
|
+
"sentCardNote": "_SVViG_sentCardNote",
|
|
7657
|
+
"editorFooter": "_SVViG_editorFooter",
|
|
7658
|
+
"badgeSent": "_SVViG_badgeSent",
|
|
7659
|
+
"editorAskRow": "_SVViG_editorAskRow",
|
|
7654
7660
|
"editorAsk": "_SVViG_editorAsk",
|
|
7655
|
-
"editorSpacer": "_SVViG_editorSpacer",
|
|
7656
7661
|
"hint": "_SVViG_hint",
|
|
7657
|
-
"
|
|
7658
|
-
"
|
|
7659
|
-
"toolbar": "_SVViG_toolbar",
|
|
7660
|
-
"saveButton": "_SVViG_saveButton",
|
|
7662
|
+
"toolbarButton": "_SVViG_toolbarButton",
|
|
7663
|
+
"editorTarget": "_SVViG_editorTarget",
|
|
7661
7664
|
"editorError": "_SVViG_editorError",
|
|
7662
|
-
"
|
|
7663
|
-
"
|
|
7664
|
-
"
|
|
7665
|
-
"editorAskRow": "_SVViG_editorAskRow"
|
|
7665
|
+
"sentCardQuote": "_SVViG_sentCardQuote",
|
|
7666
|
+
"sentChipRow": "_SVViG_sentChipRow",
|
|
7667
|
+
"editorSpacer": "_SVViG_editorSpacer"
|
|
7666
7668
|
};
|
|
7667
7669
|
//#endregion
|
|
7668
7670
|
//#region src/client/annotate/hint.tsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-sidenote",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "DSH web plugin: Codex-style side chat (fork the current session into a persistent side panel) + selection annotations with numbered badges and a composer chip. Runs directly on the DSH native right sidebar (DSH ≥ 0.1.5); dsh-better-sidebar is an optional peer for older hosts. / Codex 风格侧边聊天 + 划选注释的 DSH 插件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* 点击弹 Menu 切换(原生同路径:`session.command('/permission <id>')`)。
|
|
4
4
|
*
|
|
5
5
|
* 数据:session.projections.faceOf('permissions')(off-face——缺席则 chip
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* 不渲染)。快照 = 宿主的 wire view,只有一个 currentValue 字段
|
|
7
|
+
* (dsh-permission-presets 的 wire.viewSchema = { currentValue };权威见
|
|
8
|
+
* 该包 lib/types 的 selectionSchema)——{preset, sandbox, approval} 是投影
|
|
9
|
+
* **内部 state**(stateSchema),客户端拿不到,读它会让 chip 恒显示默认档。
|
|
8
10
|
*/
|
|
9
11
|
import { useMemo, useState, useSyncExternalStore } from 'react'
|
|
10
12
|
import { Menu, type MenuEntry } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
@@ -14,11 +16,9 @@ import { t } from '../locales.ts'
|
|
|
14
16
|
import { useLocaleTick } from '../locale-tick.ts'
|
|
15
17
|
import css from './sidechat.module.css'
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
sandbox?: string | null
|
|
21
|
-
approval?: string | null
|
|
19
|
+
/** 宿主 permissions 投影的 wire view(selector 快照形状)。 */
|
|
20
|
+
interface PermissionSnapshot {
|
|
21
|
+
currentValue?: string
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/** preset 机器值 → 展示名(宿主 displayPermissionPreset 同款:Full access 特例)。 */
|
|
@@ -30,7 +30,7 @@ function presetLabel(preset: string): string {
|
|
|
30
30
|
.join(' ')
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/**
|
|
33
|
+
/** 宿主默认表里 chip 菜单列出的档位(其余档位仍可由 /permission 切换)。 */
|
|
34
34
|
const KNOWN_PRESETS = ['workspace-write', 'danger-full-access'] as const
|
|
35
35
|
|
|
36
36
|
export function PermissionChip(props: { session: SessionFace | undefined }) {
|
|
@@ -43,14 +43,14 @@ export function PermissionChip(props: { session: SessionFace | undefined }) {
|
|
|
43
43
|
return typeof p?.projections?.faceOf === 'function' ? p.projections.faceOf('permissions') : undefined
|
|
44
44
|
}, [props.session])
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const snapshot = useSyncExternalStore(
|
|
47
47
|
(fn) => face?.subscribe(fn) ?? (() => {}),
|
|
48
|
-
() => (face?.getSnapshot() as
|
|
48
|
+
() => (face?.getSnapshot() as PermissionSnapshot | undefined) ?? null,
|
|
49
49
|
)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const effective =
|
|
51
|
+
// 快照缺席(老宿主没有该投影 key)→ chip 不渲染。
|
|
52
|
+
if (face === undefined || snapshot === null) return null
|
|
53
|
+
const effective = snapshot.currentValue ?? 'workspace-write'
|
|
54
54
|
|
|
55
55
|
const items: MenuEntry[] = KNOWN_PRESETS.map(id => ({
|
|
56
56
|
id,
|