Move context ring to footer right edge on compact
This commit is contained in:
@@ -186,20 +186,34 @@ function buildAgentStateSelector(serverId: string, agentId: string) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderContextWindowMeterSlot(
|
function renderContextWindowMeter(
|
||||||
contextWindowMaxTokens: number | null,
|
contextWindowMaxTokens: number | null,
|
||||||
contextWindowUsedTokens: number | null,
|
contextWindowUsedTokens: number | null,
|
||||||
totalCostUsd: number | null,
|
totalCostUsd: number | null,
|
||||||
): ReactElement {
|
): ReactElement | null {
|
||||||
const meter =
|
if (contextWindowMaxTokens === null || contextWindowUsedTokens === null) {
|
||||||
contextWindowMaxTokens !== null && contextWindowUsedTokens !== null ? (
|
return null;
|
||||||
<ContextWindowMeter
|
}
|
||||||
maxTokens={contextWindowMaxTokens}
|
return (
|
||||||
usedTokens={contextWindowUsedTokens}
|
<ContextWindowMeter
|
||||||
totalCostUsd={totalCostUsd}
|
maxTokens={contextWindowMaxTokens}
|
||||||
/>
|
usedTokens={contextWindowUsedTokens}
|
||||||
) : null;
|
totalCostUsd={totalCostUsd}
|
||||||
return <View style={styles.contextWindowMeterSlot}>{meter}</View>;
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveContextWindowPlacement(
|
||||||
|
meter: ReactElement | null,
|
||||||
|
isMobile: boolean,
|
||||||
|
): { beforeVoiceContent: ReactNode; footerRight: ReactNode } {
|
||||||
|
if (isMobile) {
|
||||||
|
return { beforeVoiceContent: null, footerRight: meter };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
beforeVoiceContent: <View style={styles.contextWindowMeterSlot}>{meter}</View>,
|
||||||
|
footerRight: null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RenderLeftContentArgs {
|
interface RenderLeftContentArgs {
|
||||||
@@ -224,11 +238,14 @@ interface RenderAttachmentTrayArgs {
|
|||||||
handleRemoveAttachment: (index: number) => void;
|
handleRemoveAttachment: (index: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderComposerFooter(footer: ReactNode): ReactElement | null {
|
function renderComposerFooter(footer: ReactNode, footerRight: ReactNode): ReactElement | null {
|
||||||
if (!footer) return null;
|
if (!footer && !footerRight) return null;
|
||||||
return (
|
return (
|
||||||
<View style={styles.footer}>
|
<View style={styles.footer}>
|
||||||
<View style={styles.footerContent}>{footer}</View>
|
<View style={styles.footerContent}>
|
||||||
|
<View style={styles.footerLeft}>{footer}</View>
|
||||||
|
<View style={styles.footerRight}>{footerRight}</View>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1441,15 +1458,19 @@ export function Composer({
|
|||||||
agentState.contextWindowUsedTokens,
|
agentState.contextWindowUsedTokens,
|
||||||
);
|
);
|
||||||
|
|
||||||
const beforeVoiceContent = useMemo(
|
const contextWindowMeter = useMemo(
|
||||||
() =>
|
() =>
|
||||||
renderContextWindowMeterSlot(
|
renderContextWindowMeter(
|
||||||
contextWindowMaxTokens,
|
contextWindowMaxTokens,
|
||||||
contextWindowUsedTokens,
|
contextWindowUsedTokens,
|
||||||
agentState.totalCostUsd,
|
agentState.totalCostUsd,
|
||||||
),
|
),
|
||||||
[contextWindowMaxTokens, contextWindowUsedTokens, agentState.totalCostUsd],
|
[contextWindowMaxTokens, contextWindowUsedTokens, agentState.totalCostUsd],
|
||||||
);
|
);
|
||||||
|
const { beforeVoiceContent, footerRight } = useMemo(
|
||||||
|
() => resolveContextWindowPlacement(contextWindowMeter, isMobile),
|
||||||
|
[contextWindowMeter, isMobile],
|
||||||
|
);
|
||||||
|
|
||||||
const githubSearchQueryTrimmed = githubSearchQuery.trim();
|
const githubSearchQueryTrimmed = githubSearchQuery.trim();
|
||||||
const githubSearchResultsQuery = useGithubSearchQuery({
|
const githubSearchResultsQuery = useGithubSearchQuery({
|
||||||
@@ -1693,7 +1714,7 @@ export function Composer({
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{renderComposerFooter(footer)}
|
{renderComposerFooter(footer, footerRight)}
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1737,10 +1758,27 @@ const styles = StyleSheet.create((theme: Theme) => ({
|
|||||||
footerContent: {
|
footerContent: {
|
||||||
width: "100%",
|
width: "100%",
|
||||||
maxWidth: MAX_CONTENT_WIDTH,
|
maxWidth: MAX_CONTENT_WIDTH,
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
paddingLeft: {
|
paddingLeft: {
|
||||||
xs: 6,
|
xs: 6,
|
||||||
md: 10,
|
md: 10,
|
||||||
},
|
},
|
||||||
|
paddingRight: {
|
||||||
|
xs: 6,
|
||||||
|
md: 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
footerLeft: {
|
||||||
|
flexShrink: 1,
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
footerRight: {
|
||||||
|
flexShrink: 0,
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
messageInputContainer: {
|
messageInputContainer: {
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
|||||||
Reference in New Issue
Block a user