Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions app/src/ai/blocklist/controller/input_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub(super) fn input_context_for_request(
{
let session_context = SessionContext::from_session(active_session, app);
if session_context.is_remote() {
add_remote_codebase_context(&mut context, app);
add_remote_codebase_context(&mut context, &session_context, app);
} else {
add_local_codebase_context(&mut context, app);
}
Expand Down Expand Up @@ -118,8 +118,15 @@ fn add_local_codebase_context(context: &mut Vec<AIAgentContext>, app: &AppContex
}

#[cfg(not(target_family = "wasm"))]
fn add_remote_codebase_context(context: &mut Vec<AIAgentContext>, app: &AppContext) {
for codebase in RemoteCodebaseIndexModel::as_ref(app).codebases_for_agent_context() {
fn add_remote_codebase_context(
context: &mut Vec<AIAgentContext>,
session_context: &SessionContext,
app: &AppContext,
) {
let Some(host_id) = session_context.host_id() else {
return;
};
for codebase in RemoteCodebaseIndexModel::as_ref(app).codebases_for_agent_context(host_id) {
context.push(AIAgentContext::Codebase {
name: codebase.name,
path: codebase.path,
Expand All @@ -128,7 +135,12 @@ fn add_remote_codebase_context(context: &mut Vec<AIAgentContext>, app: &AppConte
}

#[cfg(target_family = "wasm")]
fn add_remote_codebase_context(_context: &mut Vec<AIAgentContext>, _app: &AppContext) {}
fn add_remote_codebase_context(
_context: &mut Vec<AIAgentContext>,
_session_context: &SessionContext,
_app: &AppContext,
) {
}

/// Parses context reference strings like <block:123> from the user query and returns
/// a map of reference strings to AIAgentAttachment objects.
Expand Down
35 changes: 35 additions & 0 deletions app/src/ai/codebase_context_policy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#[cfg(not(target_family = "wasm"))]
use crate::features::FeatureFlag;

#[cfg(not(target_family = "wasm"))]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function just carrying this one method? If we actually want a separate module for all the policy conditions I would consider moving is_auto_indexing_enabled here as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or i can just move the remote_codebase_indexing_enabled logic out and remove the module entirely

pub(crate) fn remote_codebase_indexing_enabled(codebase_context_enabled: bool) -> bool {
FeatureFlag::RemoteCodebaseIndexing.is_enabled()
&& FeatureFlag::FullSourceCodeEmbedding.is_enabled()
&& codebase_context_enabled
}

#[cfg(test)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These unit tests seem unnecessary if they are just verifying a written out logic condition

mod tests {
use super::*;

#[cfg(not(target_family = "wasm"))]
#[test]
fn remote_indexing_requires_remote_and_fse_flags_and_codebase_context() {
{
let _remote_flag = FeatureFlag::RemoteCodebaseIndexing.override_enabled(true);
let _flag = FeatureFlag::FullSourceCodeEmbedding.override_enabled(false);
assert!(!remote_codebase_indexing_enabled(true));
}
{
let _remote_flag = FeatureFlag::RemoteCodebaseIndexing.override_enabled(true);
let _flag = FeatureFlag::FullSourceCodeEmbedding.override_enabled(true);
assert!(remote_codebase_indexing_enabled(true));
assert!(!remote_codebase_indexing_enabled(false));
}
{
let _remote_flag = FeatureFlag::RemoteCodebaseIndexing.override_enabled(false);
let _flag = FeatureFlag::FullSourceCodeEmbedding.override_enabled(true);
assert!(!remote_codebase_indexing_enabled(true));
}
}
}
Loading
Loading