@huaweidevtools/aishell-dsh-client-credentials 0.0.2 → 0.0.3
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 +70 -5
- package/lib/types/client/AishellHeroChip.d.ts +17 -10
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -654,10 +654,71 @@ function AishellAccountHint(props) {
|
|
|
654
654
|
//#region src/client/AishellHeroChip.tsx
|
|
655
655
|
ensureChipStyles();
|
|
656
656
|
function AishellHeroChip(props) {
|
|
657
|
+
const blank = props.useSession((session) => session.blank);
|
|
657
658
|
const status = props.useCredentials((snapshot) => snapshot);
|
|
659
|
+
const { mode, busy, toggle } = usePermissionMode();
|
|
658
660
|
const t = props.t;
|
|
659
661
|
const configured = Boolean(status.accessKeyIdHint);
|
|
660
|
-
const
|
|
662
|
+
const wrapperRef = (0, react.useRef)(null);
|
|
663
|
+
const [presetOffset, setPresetOffset] = (0, react.useState)(null);
|
|
664
|
+
const presetOffsetRef = (0, react.useRef)(null);
|
|
665
|
+
const applyOffset = (offset) => {
|
|
666
|
+
presetOffsetRef.current = offset;
|
|
667
|
+
setPresetOffset(offset);
|
|
668
|
+
};
|
|
669
|
+
(0, react.useLayoutEffect)(() => {
|
|
670
|
+
let observer;
|
|
671
|
+
let observedRow;
|
|
672
|
+
const measure = () => {
|
|
673
|
+
const wrapper = wrapperRef.current;
|
|
674
|
+
if (wrapper === null) return;
|
|
675
|
+
let stack = wrapper.parentElement;
|
|
676
|
+
while (stack !== null && getComputedStyle(stack).display === "contents") stack = stack.parentElement;
|
|
677
|
+
const preset = stack?.querySelector("[data-slot=\"conversation.hero.agentPreset\"] > *") ?? null;
|
|
678
|
+
if (stack === null || preset === null) {
|
|
679
|
+
applyOffset(null);
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const offset = Math.round(preset.getBoundingClientRect().right - stack.getBoundingClientRect().left + 6);
|
|
683
|
+
if (!(offset > 0)) {
|
|
684
|
+
applyOffset(null);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
applyOffset(offset);
|
|
688
|
+
const row = preset.closest("[data-slot=\"conversation.hero.agentPreset\"]")?.parentElement ?? null;
|
|
689
|
+
if (row === null || row === observedRow) return;
|
|
690
|
+
observedRow = row;
|
|
691
|
+
observer?.disconnect();
|
|
692
|
+
observer = new ResizeObserver(measure);
|
|
693
|
+
for (const target of row.querySelectorAll("button")) observer.observe(target);
|
|
694
|
+
};
|
|
695
|
+
presetOffsetRef.current = null;
|
|
696
|
+
const SWEEP_CAP_MS = 5e3;
|
|
697
|
+
const deadline = Date.now() + SWEEP_CAP_MS;
|
|
698
|
+
let settled = false;
|
|
699
|
+
let sweepTimer = 0;
|
|
700
|
+
const sweep = () => {
|
|
701
|
+
if (settled) return;
|
|
702
|
+
if (presetOffsetRef.current !== null || Date.now() > deadline) {
|
|
703
|
+
settled = true;
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
measure();
|
|
707
|
+
if (presetOffsetRef.current !== null) {
|
|
708
|
+
settled = true;
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
sweepTimer = window.setTimeout(sweep, 100);
|
|
712
|
+
};
|
|
713
|
+
sweepTimer = window.setTimeout(sweep, 100);
|
|
714
|
+
return () => {
|
|
715
|
+
settled = true;
|
|
716
|
+
observer?.disconnect();
|
|
717
|
+
window.clearTimeout(sweepTimer);
|
|
718
|
+
};
|
|
719
|
+
}, [blank]);
|
|
720
|
+
if (!blank) return null;
|
|
721
|
+
const placed = presetOffset !== null;
|
|
661
722
|
const pillStyle = {
|
|
662
723
|
display: "inline-flex",
|
|
663
724
|
alignItems: "center",
|
|
@@ -675,12 +736,15 @@ function AishellHeroChip(props) {
|
|
|
675
736
|
whiteSpace: "nowrap"
|
|
676
737
|
};
|
|
677
738
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
739
|
+
ref: wrapperRef,
|
|
678
740
|
style: {
|
|
679
741
|
display: "inline-flex",
|
|
680
742
|
alignItems: "center",
|
|
681
743
|
gap: 2,
|
|
682
744
|
minWidth: 0,
|
|
683
|
-
|
|
745
|
+
visibility: placed ? "visible" : "hidden",
|
|
746
|
+
marginTop: -33,
|
|
747
|
+
marginLeft: presetOffset ?? 0,
|
|
684
748
|
flex: "none"
|
|
685
749
|
},
|
|
686
750
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
@@ -1269,10 +1333,11 @@ function apply(ctx) {
|
|
|
1269
1333
|
t
|
|
1270
1334
|
})
|
|
1271
1335
|
}, AishellAccountHint)), "aishell-credentials: account hint chip");
|
|
1272
|
-
ctx.effect(() => ctx.slots.inject("conversation.
|
|
1336
|
+
ctx.effect(() => ctx.slots.inject("conversation.input.dock", () => {
|
|
1273
1337
|
const dispose = ctx.slots.register({
|
|
1274
|
-
name: "conversation.
|
|
1275
|
-
|
|
1338
|
+
name: "conversation.input.dock",
|
|
1339
|
+
id: "aishell-hero",
|
|
1340
|
+
order: 10,
|
|
1276
1341
|
locale: NS,
|
|
1277
1342
|
inject: () => ({ hooks: { credentials: status } })
|
|
1278
1343
|
}, AishellHeroChip);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compact account + permission chip for the New-Session hero
|
|
2
|
+
* Compact account + permission chip for the New-Session hero.
|
|
3
3
|
*
|
|
4
4
|
* The composer chip lives under the input bar, which DSH does not render until
|
|
5
5
|
* a session exists — its slot is guarded by `variant === "composer" && input
|
|
@@ -7,13 +7,20 @@
|
|
|
7
7
|
* neither the account nor the permission mode, which are exactly the two facts
|
|
8
8
|
* worth checking before sending the first message.
|
|
9
9
|
*
|
|
10
|
-
* This renders into `conversation.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* This renders into `conversation.input.dock`, the band between the hero
|
|
11
|
+
* workspace row and the input card. That band is a `list` slot, chosen over
|
|
12
|
+
* the hero row's `single` seats precisely because both of those are held by
|
|
13
|
+
* official occupants on 0.2.1-alpha.1 — ui-workspace's WorkspacePicker in
|
|
14
|
+
* `conversation.hero.workspace` (shadowing it by `priority: -1` is what
|
|
15
|
+
* silently killed the workspace menu) and ui-agent-preset's seat in
|
|
16
|
+
* `conversation.hero.agentPreset`. A `list` entry composes beside the others
|
|
17
|
+
* (the TodoPanel precedent) instead of competing for a seat, so it cannot
|
|
18
|
+
* collide with an occupant however the base evolves.
|
|
19
|
+
*
|
|
20
|
+
* The dock band renders in BOTH the hero and the session composer (it only
|
|
21
|
+
* needs a live input zone), while the composer-dock chip covers the session
|
|
22
|
+
* posture — so this entry gates itself on `session.blank` and renders nothing
|
|
23
|
+
* once a conversation exists, keeping exactly one chip on screen at a time.
|
|
17
24
|
*
|
|
18
25
|
* ## Relationship to the composer chip
|
|
19
26
|
*
|
|
@@ -21,7 +28,7 @@
|
|
|
21
28
|
* as, and whether mutations are allowed — and a person should not have to
|
|
22
29
|
* learn two shapes. They carry the same mark, the same colour pair, and the
|
|
23
30
|
* same two affordances (open Settings, toggle the mode); they differ only in
|
|
24
|
-
* the width each surface affords, which is why
|
|
31
|
+
* the width each surface affords, which is why this chip clamps the
|
|
25
32
|
* account name with `maxWidth` instead of letting it run to the row's edge.
|
|
26
33
|
*
|
|
27
34
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client/AishellHeroChip
|
|
@@ -38,6 +45,6 @@ export interface AishellHeroChipInjected {
|
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
47
|
/** Full component props: slot owner share + locale seat + inject face. */
|
|
41
|
-
export type AishellHeroChipProps = PropsRuntime<'conversation.
|
|
48
|
+
export type AishellHeroChipProps = PropsRuntime<'conversation.input.dock'> & PropsLocale<'aishell'> & InjectFace<AishellHeroChipInjected>;
|
|
42
49
|
export declare function AishellHeroChip(props: AishellHeroChipProps): ReactNode;
|
|
43
50
|
//# sourceMappingURL=AishellHeroChip.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaweidevtools/aishell-dsh-client-credentials",
|
|
3
3
|
"description": "AI Shell credentials settings panel — web form for storing Huawei Cloud AK/SK in the credential store",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"license": "Apache-2.0",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.
|
|
44
|
+
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.3"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@deepseek-ai/cordis": "^4.0.4",
|