@Composable
fun DrawerContent(
    onNewClick: () -> Unit = { },
    onSaveClick: () -> Unit = { },
    onFileClick: (Path) -> Unit = { },
    onFileLongClick: (Path) -> Unit = { },
    onDirectoryLongClick: (Path) -> Unit = { },
    onOpenFolderClick: () -> Unit = { },
    currentTab: EditorTabState?,
    GPTChatList: List<GPTMessage>,
    companionEvents: CompanionEventBus,
    GptMessageComposable: @Composable (Int, GPTMessage, Modifier) -> Unit,
    DrawerEventBus: DrawerEventBus,
) {
    val appName = stringResource(id = R.string.app_name)

    val annotatedString = buildAnnotatedString {
        var start = 0
        while (start < demoString.length) {
            val index = demoString.indexOf("cat", start)
            if (index == -1) {
                append(demoString.substring(start))
                break
            } else {
                append(demoString.substring(start, index))
                withStyle(style = SpanStyle(color = ColorPalette.yellowHighlight)) {
                    append(demoString.substring(index, index + 3))
                }
                start = index + 3
            }
        }
    }
    var selectedTab by remember {
        mutableStateOf(0)
    }
    val permissionsProvider = LocalPermissionsProvider.current
    val isStoragePermissionGranted by permissionsProvider.isStoragePermissionGranted.collectAsState()
    val context = LocalContext.current
    val dirs = remember(currentTab) {
        if (currentTab?.isproject == true) {
            Log.wtf(
                "DrawerContent",
                "currentTab?.filePath: ${currentTab?.filePath}"
            )
            return@remember File(currentTab?.filePath ?: "").parentFile
        }

        // Get the external files directory for your app
        val externalStorageDirectory =
            Environment.getExternalStorageDirectory() // Returns /storage/emulated/0 or similar

//        val appSpecificExternalDir =
//        context.getExternalFilesDir(null) // Returns /storage/emulated/0/Android/data/your_package_name/files
        // Create a new directory called "Projects" inside the app-specific external directory
        val projectsDirectory = File(externalStorageDirectory, "/")

        if (!projectsDirectory.exists()) {
            // Attempt to create the directory if it doesn't exist
            val isDirectoryCreated = projectsDirectory.mkdirs()
            if (isDirectoryCreated) {
                return@remember externalStorageDirectory
            } else {
                // Directory creation failed
                return@remember null
            }
        } else {
            // Directory already exists
            return@remember externalStorageDirectory
        }
    }
    LaunchedEffect(key1 = DrawerEventBus) {
        DrawerEventBus.events.collectLatest {
            when (it) {
                is DrawerEventBus.DrawerEvent.openCompanionScreen -> {
                    selectedTab = 1
                }
            }
        }

    }
    val tabs = remember(
        selectedTab,
        dirs,
        GPTChatList,
        companionEvents
    ) {
        listOf(
            TabItem(
                title = "Project",
                icon = R.drawable.home_ic,
                onSelected = {
                    selectedTab = 0
                },
                screen = {
                    ProjectScreen(
                        rootDirectory = dirs,
                        onOpenFolderClick = {
                            permissionsProvider.onOpenFolder()
                        },
                        onNewClick = {
                            onNewClick()
                        },
                        onSaveClick = {
                            onSaveClick()
                        },
                        onFileClick = {
                            onFileClick(it)
                        },
                        onFileLongClick = {
                            onFileLongClick(it)
                        },
                        onDirectoryLongClick = {
                            onDirectoryLongClick(it)
                        }
                    )
                }
            ),
            TabItem(
                title = "Tools",
                icon = R.drawable.interpreter,
                onSelected = {
                    selectedTab = 1
                },
                screen = {
                    TerminalScreen(
                        TerminalText = annotatedString,
                        InterpreterText = annotatedString,
                        messagesList = GPTChatList,
                        messageComposable = GptMessageComposable,
                        events = companionEvents,
                        drawerEventBus = DrawerEventBus
                    )
                }
            ),
            TabItem(
                title = "Analysis",
                icon = R.drawable.analysis_ic,
                onSelected = {
                    selectedTab = 2
                },
                screen = {
                    AnalysisScreen()
                }
            ),
            TabItem(
                title = "Download",
                icon = R.drawable.download_ic,
                onSelected = {
                    selectedTab = 3
                },
                screen = {
                    DownloadScreen()
                }
            ),
            TabItem(
                title = "Settings",
                icon = R.drawable.settings,
                onSelected = {
                    selectedTab = 4
                },
                screen = {
                    SettingsScreen()
                }
            ),

            )
    }
    Column(
        modifier = Modifier.width(340.dp),
    ) {
        val colors = LocalSettingsData.current.themeColors()
        TopDrawerSection(openTab = currentTab)
        BottomDrawerSection(tabs = tabs, selectedTab = selectedTab)
//        AnimatedContent(targetState = selectedTab, transitionSpec = {
//
//            slideInHorizontally { it } togetherWith slideOutHorizontally { -it } + fadeOut()
//        }) { it ->
//            tabs[it].screen()
//        }
        if (isStoragePermissionGranted) {
            var previousTab by remember { mutableStateOf(selectedTab) }
            AnimatedContent(
                targetState = selectedTab,
                transitionSpec = {
                    val direction = if (targetState > previousTab) 1 else -1
                    slideInHorizontally { direction * it } togetherWith slideOutHorizontally { -direction * it } + fadeOut()
                },

                ) { it ->
                tabs[it].screen()
            }

            // Update previousTab after the animation
            LaunchedEffect(selectedTab) {
                previousTab = selectedTab
            }
        } else {

            PermissionsDrawerContent(
                Modifier
                    .fillMaxSize()
                    .background(colors.drawerbg)
                    .padding(16.dp),
            ) {
                permissionsProvider.requestStoragePermission()
            }
        }
    }


}
@Composable
fun ProjectScreen(
    rootDirectory: File? = null,
    onNewClick: () -> Unit = { },
    onSaveClick: () -> Unit = { },

    onOpenFolderClick: () -> Unit = { },
    onFileClick: (Path) -> Unit,
    onFileLongClick: (Path) -> Unit,
    onDirectoryLongClick: (Path) -> Unit,
) {
    val colors = LocalSettingsData.current.themeColors()
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(colors.drawerbg),
    ) {

        OptionsRow(modifier = Modifier.fillMaxWidth(),
            listOf(
                Option(
                    title = "New",
                    icon = R.drawable.resource_new,
                    onClick = {
                        onNewClick()
                    }
                ),
                Option(
                    title = "Open Folder",
                    icon = R.drawable.openfolder_option,
                    onClick = {
                        onOpenFolderClick()

                    }
                ),
                Option(
                    title = "Open",
                    icon = R.drawable.openfolder_option,
                    onClick = {}
                ),
                Option(
                    title = "Save",
                    icon = R.drawable.save,
                    onClick = {
                        onSaveClick()
                    }
                ),
                Option(
                    title = "Save As",
                    icon = R.drawable.saveas,
                    onClick = {}
                ),
            )
        )
        BonsaiContent(
            tree = composeTree(
                rootDirectory = rootDirectory
            ), modifier = Modifier.fillMaxSize(),
            onFileClick = { path ->
                onFileClick(path)

            },
            onFileLongClick = { path ->
                onFileLongClick(path)
            },
            onDirectoryLongClick = { path ->
                onDirectoryLongClick(path)
            }
        )


    }

}
Why does the projectscreen not recompose when Dirs change?