File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Text } from "@components/text" ;
22import type { McpApprovalState } from "@posthog/api-client/types" ;
3- import { isStdioMcpServer } from "@posthog/core/mcp-servers/presentation" ;
43import { router , useLocalSearchParams } from "expo-router" ;
54import {
65 ArrowsClockwise ,
@@ -29,6 +28,7 @@ import {
2928 useUpdateMcpToolApproval ,
3029} from "@/features/mcp/hooks" ;
3130import { reauthorizeInstallation } from "@/features/mcp/oauth" ;
31+ import { isStdioMcpServer } from "@/features/mcp/presentation" ;
3232import { getMcpConnectionManager } from "@/features/mcp/service" ;
3333import { useScreenInsets } from "@/hooks/useScreenInsets" ;
3434import { logger } from "@/lib/logger" ;
Original file line number Diff line number Diff line change 11import { Text } from "@components/text" ;
2- import { isStdioMcpServer } from "@posthog/core/mcp-servers/presentation" ;
32import { router , useLocalSearchParams } from "expo-router" ;
43import { Lock , Warning } from "phosphor-react-native" ;
54import { useMemo , useState } from "react" ;
@@ -18,6 +17,7 @@ import {
1817 useMcpMarketplace ,
1918} from "@/features/mcp/hooks" ;
2019import { installTemplateWithOAuth } from "@/features/mcp/oauth" ;
20+ import { isStdioMcpServer } from "@/features/mcp/presentation" ;
2121import { useScreenInsets } from "@/hooks/useScreenInsets" ;
2222import { logger } from "@/lib/logger" ;
2323import { openExternalUrl } from "@/lib/openExternalUrl" ;
Original file line number Diff line number Diff line change 11import {
22 attributionLabel ,
3- parseDiffLines ,
4- selectActivityArtefacts ,
5- shortSha ,
63 taskRunLabel ,
74} from "@posthog/core/inbox/activityLog" ;
85import type { AnySignalReportArtefact } from "@posthog/shared/domain-types" ;
96import { describe , expect , it } from "vitest" ;
7+ import {
8+ parseDiffLines ,
9+ selectActivityArtefacts ,
10+ shortSha ,
11+ } from "./activityLog" ;
1012
1113function commit ( id : string , createdAt : string ) : AnySignalReportArtefact {
1214 return {
Original file line number Diff line number Diff line change 1+ import type { AnySignalReportArtefact } from "@posthog/shared/domain-types" ;
2+
3+ export type ActivityArtefact = Extract <
4+ AnySignalReportArtefact ,
5+ { type : "commit" | "task_run" }
6+ > ;
7+
8+ export function selectActivityArtefacts (
9+ artefacts : AnySignalReportArtefact [ ] ,
10+ ) : ActivityArtefact [ ] {
11+ return artefacts
12+ . filter (
13+ ( artefact ) : artefact is ActivityArtefact =>
14+ artefact . type === "commit" || artefact . type === "task_run" ,
15+ )
16+ . sort ( ( left , right ) => left . created_at . localeCompare ( right . created_at ) ) ;
17+ }
18+
19+ export function shortSha ( sha : string ) : string {
20+ return sha . slice ( 0 , 12 ) ;
21+ }
22+
23+ export type DiffLineKind = "add" | "del" | "hunk" | "context" ;
24+
25+ export interface DiffLine {
26+ text : string ;
27+ kind : DiffLineKind ;
28+ }
29+
30+ export function parseDiffLines ( diff : string ) : DiffLine [ ] {
31+ return diff
32+ . replace ( / \n $ / , "" )
33+ . split ( "\n" )
34+ . map ( ( text ) => {
35+ if ( text . startsWith ( "+" ) && ! text . startsWith ( "+++" ) ) {
36+ return { text, kind : "add" as const } ;
37+ }
38+ if ( text . startsWith ( "-" ) && ! text . startsWith ( "---" ) ) {
39+ return { text, kind : "del" as const } ;
40+ }
41+ if ( text . startsWith ( "@@" ) ) return { text, kind : "hunk" as const } ;
42+ return { text, kind : "context" as const } ;
43+ } ) ;
44+ }
Original file line number Diff line number Diff line change 11import { Text } from "@components/text" ;
2- import { shortSha } from "@posthog/core/inbox/activityLog" ;
32import type { CommitContent } from "@posthog/shared/domain-types" ;
43import { CaretDown , CaretRight } from "phosphor-react-native" ;
54import { useState } from "react" ;
65import { ActivityIndicator , Pressable , View } from "react-native" ;
76import { useThemeColors } from "@/lib/theme" ;
7+ import { shortSha } from "../activityLog" ;
88import { useCommitDiff } from "../hooks/useInboxReports" ;
99import { DiffBlock } from "./DiffBlock" ;
1010
Original file line number Diff line number Diff line change 11import { Text } from "@components/text" ;
2- import { parseDiffLines } from "@posthog/core/inbox/activityLog" ;
32import { ScrollView , View } from "react-native" ;
3+ import { parseDiffLines } from "../activityLog" ;
44
55const LINE_CLASS : Record < string , string > = {
66 add : "bg-status-success/15 text-status-success" ,
Original file line number Diff line number Diff line change 11import { Text } from "@components/text" ;
2- import {
3- type ActivityArtefact ,
4- attributionLabel ,
5- selectActivityArtefacts ,
6- } from "@posthog/core/inbox/activityLog" ;
2+ import { attributionLabel } from "@posthog/core/inbox/activityLog" ;
73import type { AnySignalReportArtefact } from "@posthog/shared/domain-types" ;
84import { ClockCounterClockwise } from "phosphor-react-native" ;
95import { useMemo } from "react" ;
106import { View } from "react-native" ;
117import { formatRelativeTime } from "@/lib/format" ;
128import { useThemeColors } from "@/lib/theme" ;
9+ import { type ActivityArtefact , selectActivityArtefacts } from "../activityLog" ;
1310import { ArtefactCommit } from "./ArtefactCommit" ;
1411import { ArtefactTaskRun } from "./ArtefactTaskRun" ;
1512
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ import type {
33 McpRecommendedServer ,
44 McpServerInstallation ,
55} from "@posthog/api-client/types" ;
6- import { isStdioMcpServer } from "@posthog/core/mcp-servers/presentation" ;
76import { CaretRight , Lock , Warning } from "phosphor-react-native" ;
87import type { ReactNode } from "react" ;
98import { Pressable , View } from "react-native" ;
109import { useThemeColors } from "@/lib/theme" ;
10+ import { isStdioMcpServer } from "../presentation" ;
1111import { ServerIcon } from "./ServerIcon" ;
1212
1313interface McpServerRowProps {
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import type {
44 McpInstallResponse ,
55 McpServerInstallation ,
66} from "@posthog/api-client/types" ;
7- import { isMcpOAuthRedirect } from "@posthog/core/mcp-servers/presentation" ;
87import * as Linking from "expo-linking" ;
98import * as WebBrowser from "expo-web-browser" ;
109import { getPostHogApiClient } from "@/lib/posthogApiClient" ;
10+ import { isMcpOAuthRedirect } from "./presentation" ;
1111
1212/** Custom URL scheme registered via app.json (`scheme: "posthog"`). The cloud
1313 * bounces the OAuth redirect back to this URL once the provider completes
File renamed without changes.
You can’t perform that action at this time.
0 commit comments